Add files via upload
This commit is contained in:
10
Ghost.ipynb
10
Ghost.ipynb
@@ -261,14 +261,14 @@
|
||||
"# Who Wins?\n",
|
||||
"\n",
|
||||
"Who wins a game if both players play rationally? To answer that, consider the general situation at some point\n",
|
||||
"suring the game where\n",
|
||||
"during the game where\n",
|
||||
"a player is presented with a fragment. That player can win if either:\n",
|
||||
"- The fragment is a word (meaning the other player formed the word, and lost).\n",
|
||||
"- The fragment is not a legal fragment (meaning the other player made a mistake, and lost).\n",
|
||||
"- At least one of the legal plays puts the opponent in a position from which they *cannot* win.\n",
|
||||
"- At least one of the legal plays in this position puts the opponent in a position from which they *cannot* win.\n",
|
||||
"\n",
|
||||
"The function `win(vocab, fragment)` implements this idea. It returns a winning fragment if there is one, otherwise `None`. In particular, it returns `fragment` if the current player has already won because `fragment` forms\n",
|
||||
"a word or illegal fragment, and it returns one of the legal plays if the play leads to a position from\n",
|
||||
"The function `win(vocab, fragment)` implements this. It returns a winning fragment if there is one, otherwise `False`. In particular, it returns `fragment` if the current player has already won (because `fragment` is\n",
|
||||
"a word or illegal fragment), and it returns one of the legal plays if the play leads to a position from\n",
|
||||
"which the opponent *cannot* `win`."
|
||||
]
|
||||
},
|
||||
@@ -282,7 +282,7 @@
|
||||
"source": [
|
||||
"def win(vocab, fragment=''):\n",
|
||||
" \"\"\"Does the current player have a forced win? \n",
|
||||
" Return fragment if the player has already won, or return a play that forces a win.\"\"\"\n",
|
||||
" If so, return a play (or the current fragment) that leads to a win.\"\"\"\n",
|
||||
" if fragment in vocab.words or fragment not in vocab.fragments:\n",
|
||||
" return fragment\n",
|
||||
" for play in vocab.legal_plays(fragment):\n",
|
||||
|
||||
Reference in New Issue
Block a user