{
"metadata": {
"name": "",
- "signature": "sha256:6b8d6551e13b3d60196077d54315af6fd1f78b4de386098da7115fe7cf3112fb"
+ "signature": "sha256:07f366ec645d178071697c25c43d438fd80cf3a676ad9bd8d7613f5bfa36adf5"
},
"nbformat": 3,
"nbformat_minor": 0,
"language": "python",
"metadata": {},
"outputs": [],
- "prompt_number": 37
+ "prompt_number": 5
},
{
"cell_type": "code",
"output_type": "stream",
"stream": "stdout",
"text": [
- "42\n"
+ "43\n"
]
}
],
- "prompt_number": 38
+ "prompt_number": 8
},
{
"cell_type": "code",
"output_type": "stream",
"stream": "stdout",
"text": [
- "330\n"
+ "316\n"
]
}
],
"output_type": "stream",
"stream": "stdout",
"text": [
- "8\n"
+ "5\n"
]
}
],
"output_type": "stream",
"stream": "stdout",
"text": [
- "472\n"
+ "473\n"
]
}
],
"output_type": "stream",
"stream": "stdout",
"text": [
- "452\n"
+ "489\n"
]
}
],
"output_type": "stream",
"stream": "stdout",
"text": [
- "975\n"
+ "979\n"
]
}
],
"language": "python",
"metadata": {},
"outputs": [],
- "prompt_number": 50
+ "prompt_number": 19
},
{
"cell_type": "code",
"language": "python",
"metadata": {},
"outputs": [],
- "prompt_number": 62
+ "prompt_number": 20
},
{
"cell_type": "code",
"output_type": "stream",
"stream": "stdout",
"text": [
- "491\n"
+ "512\n"
]
}
],
- "prompt_number": 63
+ "prompt_number": 21
},
{
"cell_type": "code",
"language": "python",
"metadata": {},
"outputs": [],
- "prompt_number": 25
+ "prompt_number": 22
},
{
"cell_type": "code",
"output_type": "stream",
"stream": "stdout",
"text": [
- "995\n"
+ "990\n"
]
}
],
- "prompt_number": 27
+ "prompt_number": 23
},
{
"cell_type": "code",
"output_type": "stream",
"stream": "stdout",
"text": [
- "992\n",
- "994"
+ "986\n",
+ "996"
]
},
{
"stream": "stdout",
"text": [
"\n",
- "989"
+ "991"
]
},
{
"stream": "stdout",
"text": [
"\n",
- "1 loops, best of 3: 33.9 s per loop\n"
+ "1 loops, best of 3: 57.2 s per loop\n"
]
}
],
- "prompt_number": 28
+ "prompt_number": 24
},
{
"cell_type": "code",
"language": "python",
"metadata": {},
"outputs": [],
- "prompt_number": 29
+ "prompt_number": 25
},
{
"cell_type": "code",
"language": "python",
"metadata": {},
"outputs": [],
- "prompt_number": 30
+ "prompt_number": 26
},
{
"cell_type": "code",
"language": "python",
"metadata": {},
"outputs": [],
- "prompt_number": 31
+ "prompt_number": 27
},
{
"cell_type": "code",
"language": "python",
"metadata": {},
"outputs": [],
- "prompt_number": 32
+ "prompt_number": 28
},
{
"cell_type": "code",
"language": "python",
"metadata": {},
"outputs": [],
- "prompt_number": 33
+ "prompt_number": 29
},
{
"cell_type": "code",
"output_type": "stream",
"stream": "stdout",
"text": [
- "465\n",
- "458"
+ "463\n",
+ "492"
]
},
{
"stream": "stdout",
"text": [
"\n",
- "483"
+ "451"
]
},
{
"stream": "stdout",
"text": [
"\n",
- "482"
+ "448"
]
},
{
"stream": "stdout",
"text": [
"\n",
- "1 loops, best of 3: 18.5 s per loop\n"
+ "1 loops, best of 3: 30.9 s per loop\n"
]
}
],
- "prompt_number": 34
+ "prompt_number": 30
},
{
"cell_type": "code",
"output_type": "stream",
"stream": "stdout",
"text": [
- "976\n",
- "983"
+ "985\n",
+ "972"
]
},
{
"stream": "stdout",
"text": [
"\n",
- "983"
+ "976"
]
},
{
"stream": "stdout",
"text": [
"\n",
- "985"
+ "986"
]
},
{
"stream": "stdout",
"text": [
"\n",
- "1 loops, best of 3: 40.4 s per loop\n"
+ "1 loops, best of 3: 1min 8s per loop\n"
]
}
],
- "prompt_number": 35
+ "prompt_number": 31
},
{
"cell_type": "code",
"output_type": "stream",
"stream": "stdout",
"text": [
- "513\n",
- "507"
+ "502\n",
+ "491"
]
},
{
"stream": "stdout",
"text": [
"\n",
- "509"
+ "537"
]
},
{
"stream": "stdout",
"text": [
"\n",
- "523"
+ "524"
]
},
{
"stream": "stdout",
"text": [
"\n",
- "1 loops, best of 3: 8min 15s per loop\n"
+ "1 loops, best of 3: 13min 6s per loop\n"
]
}
],
- "prompt_number": 40
+ "prompt_number": 32
},
{
"cell_type": "code",
"output_type": "stream",
"stream": "stdout",
"text": [
- "992\n",
- "995"
+ "993\n",
+ "991"
]
},
{
"stream": "stdout",
"text": [
"\n",
- "998"
+ "994"
]
},
{
"stream": "stdout",
"text": [
"\n",
- "1 loops, best of 3: 34.4 s per loop\n"
+ "1 loops, best of 3: 56.6 s per loop\n"
]
}
],
- "prompt_number": 41
+ "prompt_number": 33
},
{
"cell_type": "code",
"collapsed": false,
"input": [
- "%%timeit\n",
- "\n",
- "wins = 0\n",
"for _ in range(1000):\n",
- " g = Game(random.choice(WORDS), player=PlayerAdaptivePatternNegLookahead(WORDS))\n",
+ " g = Game(random.choice(WORDS), player=PlayerAdaptivePattern(WORDS))\n",
" g.play_game()\n",
- " if g.game_won:\n",
- " wins += 1\n",
- "print(wins)"
+ " if not g.game_won:\n",
+ " print(g.target, g.discovered, g.wrong_letters)"
],
"language": "python",
"metadata": {},
"outputs": [
{
- "ename": "NameError",
- "evalue": "name 'PlayerAdaptivePatternNegLookahead' is not defined",
- "output_type": "pyerr",
- "traceback": [
- "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
- "\u001b[1;32m<ipython-input-42-850f0afb3e83>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mget_ipython\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mrun_cell_magic\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'timeit'\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m''\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'\\nwins = 0\\nfor _ in range(1000):\\n g = Game(random.choice(WORDS), player=PlayerAdaptivePatternNegLookahead(WORDS))\\n g.play_game()\\n if g.game_won:\\n wins += 1\\nprint(wins)'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
- "\u001b[1;32m/usr/local/lib/python3.4/dist-packages/IPython/core/interactiveshell.py\u001b[0m in \u001b[0;36mrun_cell_magic\u001b[1;34m(self, magic_name, line, cell)\u001b[0m\n\u001b[0;32m 2160\u001b[0m \u001b[0mmagic_arg_s\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mvar_expand\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mline\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mstack_depth\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2161\u001b[0m \u001b[1;32mwith\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbuiltin_trap\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 2162\u001b[1;33m \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mfn\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmagic_arg_s\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mcell\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2163\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 2164\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
- "\u001b[1;32m/usr/local/lib/python3.4/dist-packages/IPython/core/magics/execution.py\u001b[0m in \u001b[0;36mtimeit\u001b[1;34m(self, line, cell)\u001b[0m\n",
- "\u001b[1;32m/usr/local/lib/python3.4/dist-packages/IPython/core/magic.py\u001b[0m in \u001b[0;36m<lambda>\u001b[1;34m(f, *a, **k)\u001b[0m\n\u001b[0;32m 191\u001b[0m \u001b[1;31m# but it's overkill for just that one bit of state.\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 192\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mmagic_deco\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0marg\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 193\u001b[1;33m \u001b[0mcall\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;32mlambda\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m*\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mk\u001b[0m\u001b[1;33m:\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0ma\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m**\u001b[0m\u001b[0mk\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 194\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 195\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mcallable\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0marg\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
- "\u001b[1;32m/usr/local/lib/python3.4/dist-packages/IPython/core/magics/execution.py\u001b[0m in \u001b[0;36mtimeit\u001b[1;34m(self, line, cell)\u001b[0m\n\u001b[0;32m 1011\u001b[0m \u001b[0mnumber\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1012\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0m_\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m10\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1013\u001b[1;33m \u001b[1;32mif\u001b[0m \u001b[0mtimer\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtimeit\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnumber\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m>=\u001b[0m \u001b[1;36m0.2\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1014\u001b[0m \u001b[1;32mbreak\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1015\u001b[0m \u001b[0mnumber\u001b[0m \u001b[1;33m*=\u001b[0m \u001b[1;36m10\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
- "\u001b[1;32m/usr/lib/python3.4/timeit.py\u001b[0m in \u001b[0;36mtimeit\u001b[1;34m(self, number)\u001b[0m\n\u001b[0;32m 176\u001b[0m \u001b[0mgc\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdisable\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 177\u001b[0m \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 178\u001b[1;33m \u001b[0mtiming\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0minner\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mit\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mtimer\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 179\u001b[0m \u001b[1;32mfinally\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 180\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0mgcold\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
- "\u001b[1;32m<magic-timeit>\u001b[0m in \u001b[0;36minner\u001b[1;34m(_it, _timer)\u001b[0m\n",
- "\u001b[1;31mNameError\u001b[0m: name 'PlayerAdaptivePatternNegLookahead' is not defined"
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "jutting ['_', 'u', 't', 't', 'i', 'n', 'g'] ['e', 'a', 'o', 'l', 's', 'f', 'p', 'b', 'c', 'r']\n",
+ "faze"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " ['_', 'a', '_', 'e'] ['r', 'l', 'm', 'p', 's', 'g', 'b', 'd', 'v', 'k']\n",
+ "fate"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " ['_', 'a', '_', 'e'] ['r', 'l', 'm', 'p', 's', 'g', 'b', 'd', 'v', 'k']\n",
+ "dunk"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " ['_', 'u', 'n', 'k'] ['e', 's', 'o', 'a', 'i', 'l', 'f', 'r', 'j', 'p']\n",
+ "loons"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " ['_', 'o', 'o', 'n', 's'] ['e', 't', 'k', 'm', 'p', 'd', 'f', 'c', 'b', 'g']\n",
+ "lab"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " ['_', 'a', 'b'] ['t', 'p', 'g', 'w', 'm', 'd', 'y', 'r', 'c', 'n']\n",
+ "joked"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " ['_', 'o', 'k', 'e', 'd'] ['s', 'a', 'w', 'p', 't', 'r', 'h', 'b', 'y', 'c']\n"
]
}
],
- "prompt_number": 42
+ "prompt_number": 34
},
{
"cell_type": "code",
"collapsed": false,
"input": [
- "for _ in range(1000):\n",
+ "iterations = 10000\n",
+ "wins = 0\n",
+ "for _ in range(iterations):\n",
" g = Game(random.choice(WORDS), player=PlayerAdaptivePattern(WORDS))\n",
" g.play_game()\n",
- " if not g.game_won:\n",
- " print(g.target, g.discovered, g.wrong_letters)"
+ " if g.game_won:\n",
+ " wins += 1\n",
+ "print(wins / iterations)"
],
"language": "python",
"metadata": {},
- "outputs": []
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "0.9923\n"
+ ]
+ }
+ ],
+ "prompt_number": 35
},
{
"cell_type": "code",