Add files via upload
This commit is contained in:
parent
8880ffaa99
commit
9232bdb195
12
Ghost.ipynb
12
Ghost.ipynb
@ -42,7 +42,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class Vocabulary:\n",
|
||||
" \"Holds a set of legal words and set of legal prefix fragments for those words; provides legal_plays(fragment).\"\n",
|
||||
" \"Holds a set of legal words and a set of legal prefix fragments of those words.\"\n",
|
||||
" def __init__(self, words, minlength=3):\n",
|
||||
" self.words = {word for word in words if len(word) >= minlength}\n",
|
||||
" self.fragments = {word[:i] for word in self.words for i in range(len(word) + 1)}\n",
|
||||
@ -288,7 +288,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"win(Vocabulary(words('cat camel'))) # All words have odd number of letters; first player can never win"
|
||||
"win(Vocabulary(words('cat camel'))) # All words have odd number of letters; first player loses"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -332,7 +332,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"win(Vocabulary(words('cat camel goat gar'))) # Second player can avoid 'goat' with 'ga'."
|
||||
"win(Vocabulary(words('cat camel goat gar'))) # Second player can avoid 'goat' with 'ga'"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -354,7 +354,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"win(Vocabulary(words('cat camel goat gar gannet'))) # First player counters 'ga' with 'gan' to win."
|
||||
"win(Vocabulary(words('cat camel goat gar gannet'))) # First player plays 'gan' after 'ga' to win"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -587,7 +587,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def outcomes(vocab, fragment, player):\n",
|
||||
" \"The smallest set of outcomes, if player tries to win, and also tries to make the set of outcomes small.\"\n",
|
||||
" \"The smallest set of outcome words, if player tries to win, and make the set small.\"\n",
|
||||
" if fragment in vocab.words:\n",
|
||||
" return {fragment}\n",
|
||||
" else:\n",
|
||||
@ -940,7 +940,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"class SuperVocabulary(Vocabulary):\n",
|
||||
" \"Holds a set of legal words and set of legal infix fragments of those words; provides legal_plays(fragment).\" \n",
|
||||
" \"Holds a set of legal words and a set of legal infix fragments of those words.\"\n",
|
||||
" def __init__(self, words, minlength=3):\n",
|
||||
" self.words = {word for word in words if len(word) >= minlength}\n",
|
||||
" self.fragments = {word[i:j] for word in self.words \n",
|
||||
|
Loading…
Reference in New Issue
Block a user