From 1438c333bddc01aa80a1bf08c80b17faa06a9d80 Mon Sep 17 00:00:00 2001 From: Peter Norvig Date: Wed, 16 Aug 2017 21:55:48 -0700 Subject: [PATCH] Add files via upload --- Ghost.ipynb | 248 ++++++++++++++++++++++++---------------------------- 1 file changed, 113 insertions(+), 135 deletions(-) diff --git a/Ghost.ipynb b/Ghost.ipynb index 78b96c5..8241c8f 100644 --- a/Ghost.ipynb +++ b/Ghost.ipynb @@ -502,21 +502,15 @@ "name": "stdout", "output_type": "stream", "text": [ - "Player 0, given \"\", plays \"z\".\n", - "Player 1, given \"z\", plays \"zu\".\n", - "Player 0, given \"zu\", plays \"zuc\".\n", - "Player 1, given \"zuc\", plays \"zucc\".\n", - "Player 0, given \"zucc\", plays \"zucch\".\n", - "Player 1, given \"zucch\", plays \"zucche\".\n", - "Player 0, given \"zucche\", plays \"zucchet\".\n", - "Player 1, given \"zucchet\", plays \"zucchett\".\n", - "Player 0, given \"zucchett\", plays \"zucchetto\".\n" + "Player 0, given \"\", plays \"w\".\n", + "Player 1, given \"w\", plays \"wr\".\n", + "Player 0, given \"wr\", plays \"wry\".\n" ] }, { "data": { "text/plain": [ - "(1, 'zucchetto')" + "(1, 'wry')" ] }, "execution_count": 19, @@ -540,15 +534,15 @@ "output_type": "stream", "text": [ "Player 0, given \"\", plays \"n\".\n", - "Player 1, given \"n\", plays \"no\".\n", - "Player 0, given \"no\", plays \"nog\".\n", - "Player 1, given \"nog\", plays \"nogs\".\n" + "Player 1, given \"n\", plays \"ni\".\n", + "Player 0, given \"ni\", plays \"nig\".\n", + "Player 1, given \"nig\", plays \"nigh\".\n" ] }, { "data": { "text/plain": [ - "(0, 'nogs')" + "(0, 'nigh')" ] }, "execution_count": 20, @@ -573,18 +567,21 @@ "text": [ "Player 0, given \"\", plays? d\n", "Player 0, given \"\", plays \"d\".\n", - "Player 1, given \"d\", plays \"dr\".\n", - "Player 0, given \"dr\", plays? dro\n", - "Player 0, given \"dr\", plays \"dro\".\n", - "Player 1, given \"dro\", plays \"drov\".\n", - "Player 0, given \"drov\", plays? drove\n", - "Player 0, given \"drov\", plays \"drove\".\n" + "Player 1, given \"d\", plays \"dw\".\n", + "Player 0, given \"dw\", plays? dwa\n", + "Player 0, given \"dw\", plays \"dwa\".\n", + "Player 1, given \"dwa\", plays \"dwar\".\n", + "Player 0, given \"dwar\", plays? dwarv\n", + "Player 0, given \"dwar\", plays \"dwarv\".\n", + "Player 1, given \"dwarv\", plays \"dwarve\".\n", + "Player 0, given \"dwarve\", plays? dwarves\n", + "Player 0, given \"dwarve\", plays \"dwarves\".\n" ] }, { "data": { "text/plain": [ - "(1, 'drove')" + "(1, 'dwarves')" ] }, "execution_count": 21, @@ -687,7 +684,7 @@ { "data": { "text/plain": [ - "{'nazi', 'nene', 'ngultrum', 'nirvanic', 'nolo', 'null', 'nyctalopia'}" + "{'nays', 'nene', 'ngultrum', 'nirvanic', 'nolo', 'null', 'nyctalopia'}" ] }, "execution_count": 24, @@ -731,7 +728,7 @@ " 'drank',\n", " 'dreck',\n", " 'drift',\n", - " 'droll',\n", + " 'droit',\n", " 'druid',\n", " 'dry',\n", " 'ewe',\n", @@ -742,11 +739,11 @@ " 'ihram',\n", " 'jnana',\n", " 'kwashiorkor',\n", - " 'llama',\n", + " 'llano',\n", " 'mho',\n", " 'nth',\n", " 'oquassa',\n", - " 'prawn',\n", + " 'prahu',\n", " 'prequel',\n", " 'prill',\n", " 'pro',\n", @@ -766,16 +763,16 @@ " 'sjambok',\n", " 'tchotchke',\n", " 'uhlan',\n", - " 'vroom',\n", - " 'wrath',\n", + " 'vying',\n", + " 'wrang',\n", " 'wreck',\n", - " 'wrick',\n", + " 'wrist',\n", " 'wrong',\n", " 'wrung',\n", " 'wry',\n", " 'xanthic',\n", " 'xanthin',\n", - " 'yperite',\n", + " 'yttrium',\n", " 'zucchetto'}" ] }, @@ -838,7 +835,7 @@ " 'drank',\n", " 'dreck',\n", " 'drift',\n", - " 'droll',\n", + " 'droit',\n", " 'druid',\n", " 'dryness',\n", " 'eschatologies',\n", @@ -878,7 +875,7 @@ " 'ihram',\n", " 'jnana',\n", " 'kwashiorkor',\n", - " 'llama',\n", + " 'llano',\n", " 'mbira',\n", " 'ngultrum',\n", " 'ngwee',\n", @@ -903,16 +900,16 @@ " 'sjambok',\n", " 'tchotchke',\n", " 'uhlan',\n", - " 'vroom',\n", - " 'wrath',\n", + " 'vying',\n", + " 'wrang',\n", " 'wreck',\n", - " 'wrick',\n", + " 'wrist',\n", " 'wrong',\n", " 'wrung',\n", " 'wryly',\n", " 'xanthic',\n", " 'xanthin',\n", - " 'yperite',\n", + " 'yttrium',\n", " 'zucchetto'}" ] }, @@ -935,7 +932,7 @@ { "data": { "text/plain": [ - "(85, ['ngultrum', 'hyphen', 'hyte', 'hybris'])" + "(85, ['ngultrum', 'hyte', 'hyphen', 'hybris'])" ] }, "execution_count": 28, @@ -984,26 +981,6 @@ " return {play for L in alphabet for play in (fragment + L, L + fragment)} & self.fragments" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "One more thing: I'll change `ask` to ask for a fragment, not a letter:" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def ask(name='Player'):\n", - " \"Return a strategy that asks for a fragment.\"\n", - " return (lambda _, fragment: input(\"{}'s fragment, given '{}'? \".format(name, fragment)))" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -1013,7 +990,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 30, "metadata": { "collapsed": false }, @@ -1025,7 +1002,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 31, "metadata": { "collapsed": false }, @@ -1048,7 +1025,7 @@ " 'ttresse'}" ] }, - "execution_count": 32, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } @@ -1058,6 +1035,30 @@ "enable1s.legal_plays('tresse')" ] }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Can the first player win in SuperGhost with 3-letter words?\n", + "\n", + "win(enable1s)" + ] + }, { "cell_type": "code", "execution_count": 33, @@ -1076,30 +1077,6 @@ "output_type": "execute_result" } ], - "source": [ - "# Can the first player win in SuperGhost with 3-letter words?\n", - "\n", - "win(enable1s)" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 34, - "metadata": {}, - "output_type": "execute_result" - } - ], "source": [ "# How about with a 4-letter limit?\n", "\n", @@ -1115,7 +1092,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 34, "metadata": { "collapsed": false }, @@ -1124,26 +1101,29 @@ "name": "stdout", "output_type": "stream", "text": [ - "0's fragment, given ''? q\n", + "Player 0, given \"\", plays? q\n", "Player 0, given \"\", plays \"q\".\n", "Player 1, given \"q\", plays \"zq\".\n", - "0's fragment, given 'zq'? zqu\n", + "Player 0, given \"zq\", plays? zqu\n", "Player 0, given \"zq\", plays \"zqu\".\n", "Player 1, given \"zqu\", plays \"zqui\".\n", - "0's fragment, given 'zqui'? ezqui\n", - "Player 0, given \"zqui\", plays \"ezqui\".\n", - "Player 1, given \"ezqui\", plays \"mezqui\".\n", - "0's fragment, given 'mezqui'? mezquit\n", - "Player 0, given \"mezqui\", plays \"mezquit\".\n" + "Player 0, given \"zqui\", plays? zquit\n", + "Player 0, given \"zqui\", plays \"zquit\".\n", + "Player 1, given \"zquit\", plays \"zquite\".\n", + "Player 0, given \"zquite\", plays? ezquite\n", + "Player 0, given \"zquite\", plays \"ezquite\".\n", + "Player 1, given \"ezquite\", plays \"ezquites\".\n", + "Player 0, given \"ezquites\", plays? mezquites\n", + "Player 0, given \"ezquites\", plays \"mezquites\".\n" ] }, { "data": { "text/plain": [ - "(1, 'mezquit')" + "(1, 'mezquites')" ] }, - "execution_count": 35, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -1166,7 +1146,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 35, "metadata": { "collapsed": true }, @@ -1184,7 +1164,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 36, "metadata": { "collapsed": true }, @@ -1196,7 +1176,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 37, "metadata": { "collapsed": false }, @@ -1221,7 +1201,7 @@ " 'ttresse'}" ] }, - "execution_count": 38, + "execution_count": 37, "metadata": {}, "output_type": "execute_result" } @@ -1240,7 +1220,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 38, "metadata": { "collapsed": false }, @@ -1257,6 +1237,28 @@ " for play in vocab.legal_plays(fragment)))" ] }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "win(enable1sd)" + ] + }, { "cell_type": "code", "execution_count": 40, @@ -1275,28 +1277,6 @@ "output_type": "execute_result" } ], - "source": [ - "win(enable1sd)" - ] - }, - { - "cell_type": "code", - "execution_count": 41, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 41, - "metadata": {}, - "output_type": "execute_result" - } - ], "source": [ "win(enable1_4sd)" ] @@ -1310,7 +1290,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 41, "metadata": { "collapsed": false }, @@ -1319,25 +1299,23 @@ "name": "stdout", "output_type": "stream", "text": [ - "Player 0, given \"\", plays \"s\".\n", - "Player 1, given \"s\", plays \"is\".\n", - "Player 0, given \"is\", plays \"isq\".\n", - "Player 1, given \"isq\", plays \"misq\".\n", - "Player 0, given \"misq\", plays \"misqu\".\n", - "Player 1, given \"misqu\", plays \"misquo\".\n", - "Player 0, given \"misquo\", plays \"misquot\".\n", - "Player 1, given \"misquot\", plays \"misquoti\".\n", - "Player 0, given \"misquoti\", plays \"misquotin\".\n", - "Player 1, given \"misquotin\", plays \"misquoting\".\n" + "Player 0, given \"\", plays \"b\".\n", + "Player 1, given \"b\", plays \"lb\".\n", + "Player 0, given \"lb\", plays \"hlb\".\n", + "Player 1, given \"hlb\", plays \"ahlb\".\n", + "Player 0, given \"ahlb\", plays \"fahlb\".\n", + "Player 1, given \"fahlb\", plays \"fahlba\".\n", + "Player 0, given \"fahlba\", plays \"fahlban\".\n", + "Player 1, given \"fahlban\", plays \"fahlband\".\n" ] }, { "data": { "text/plain": [ - "(0, 'misquoting')" + "(0, 'fahlband')" ] }, - "execution_count": 42, + "execution_count": 41, "metadata": {}, "output_type": "execute_result" } @@ -1355,7 +1333,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 42, "metadata": { "collapsed": false }, @@ -1366,7 +1344,7 @@ "[387878, 387844, 1076434, 1076431, 1076434, 1076431]" ] }, - "execution_count": 43, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" }