Terminal state logic (#84)

* Update AIDungeon_2.ipynb

* Update AIDungeon_2.ipynb

* Update AIDungeon_2.ipynb

* Fix "Notebook loading error" on colab (#81)

* Fix "Notebook loading error" on colab

There was a missing comma after the array element on line 46, so I added it. From what I can tell, this was causing the colab to be unable to load.

* Update AIDungeon_2.ipynb

* Update requirements.txt

* improved terminal state logic.
This commit is contained in:
Benjamin Bay
2019-12-09 21:50:36 -07:00
committed by Nick Walton
parent 5edda4de88
commit 842d89d496
3 changed files with 26 additions and 35 deletions
+4 -3
View File
@@ -32,7 +32,7 @@
"If you want to help, best thing you can do is to **[download this torrent file with game files](https://github.com/nickwalton/AIDungeon/files/3935881/model_v5.torrent.zip)** and **seed it** indefinitely to the best of your ability. This will help new players download this game faster, and discover the vast worlds of AIDungeon2!\n",
"\n",
"- <a href=\"https://twitter.com/nickwalton00?ref_src=twsrc%5Etfw\" class=\"twitter-follow-button\" data-show-count=\"false\">Follow @nickwalton00</a> on Twitter for updates on when it will be available again.\n",
"- **[Support AI Dungeon 2](https://www.patreon.com/posts/update-32193930) on Patreon**\n",
"- **[Support AI Dungeon 2](https://www.patreon.com/AIDungeon) on Patreon to help me to continue improving the game with all the awesome ideas I have for its future!**\n",
"\n",
"## How to play\n",
"1. Click \"Tools\"-> \"Settings...\" -> \"Theme\" -> \"Dark\" (optional but recommended)\n",
@@ -43,7 +43,8 @@
"\n",
"## About\n",
"* While you wait you can [read adventures others have had](https://aidungeon.io/)\n",
"* [Read more](https://pcc.cs.byu.edu/2019/11/21/ai-dungeon-2-creating-infinitely-generated-text-adventures-with-deep-learning-language-models/) about how AI Dungeon 2 is made."
"* [Read more](https://pcc.cs.byu.edu/2019/11/21/ai-dungeon-2-creating-infinitely-generated-text-adventures-with-deep-learning-language-models/) about how AI Dungeon 2 is made.",
"- **[Support AI Dungeon 2](https://www.patreon.com/bePatron?u=19115449) on Patreon to help me to continue improving the game with all the awesome ideas I have for its future!**\n"
]
},
{
@@ -80,4 +81,4 @@
"outputs": []
}
]
}
}
+2 -1
View File
@@ -1,6 +1,7 @@
google-cloud-storage
gsutil
numpy
regex
profanityfilter
pyyaml
regex
tensorflow==1.15
+20 -31
View File
@@ -48,41 +48,30 @@ def get_num_options(num):
def player_died(text):
# reg_phrases = ["You[a-zA-Z ]* die.", "you[a-zA-Z ]* die.", "You[a-zA-Z ]* die ", "you[a-zA-Z ]* die ",]
#
# for phrase in reg_phrases:
# reg_expr = re.compile(phrase)
# matches = re.findall(reg_expr, text)
# if len(matches) > 0:
# return True
dead_phrases = [
"you die",
"You die",
"you died",
"you are dead",
"You died",
"You are dead",
"You're dead",
"you're dead",
"you have died",
"You have died",
"you bleed out",
"""
TODO: Add in more sophisticated NLP, maybe a custom classifier
trained on hand-labelled data that classifies second-person
statements as resulting in death or not.
"""
lower_text = text.lower()
you_dead_regexps = [
"you('re| are) (dead|killed|slain|no more|nonexistent)",
"you (die|pass away|perish|suffocate|drown|bleed out)",
"you('ve| have) (died|perished|suffocated|drowned|been (killed|slain))",
"you \w* to death",
"you \w+ yourself to death",
]
for phrase in dead_phrases:
if phrase in text:
return True
return False
return any(re.search(regexp, lower_text) for regexp in you_dead_regexps)
def player_won(text):
won_phrases = ["live happily ever after", "you live forever"]
for phrase in won_phrases:
if phrase in text:
return True
return False
lower_text = text.lower()
won_phrases = [
"live happily ever after",
"(you)? live (forever|eternally|for eternity)",
"you (are|become|turn into) (a)? (deity|god)",
]
return any(re.search(regexp, lower_text) for regexp in won_phrases)
def remove_profanity(text):