This commit is contained in:
root
2019-11-18 17:53:05 +00:00
parent ad554f70c9
commit 1355c37f5e
5 changed files with 27 additions and 16 deletions
+7 -3
View File
@@ -14,8 +14,8 @@ CRED_FILE = "./AI-Adventure-2bb65e3a4e2f.json"
def play_unconstrained():
generator = SimpleGenerator()
prompt = get_story_start("zombies")
context = get_context("zombies")
prompt = get_story_start("knight")
context = get_context("knight")
story_manager = UnconstrainedStoryManager(generator)
story_manager.start_new_story(prompt, context=context)
@@ -35,7 +35,11 @@ def play_unconstrained():
#action = first_to_second_person(action)
result = story_manager.act(action)
print(result)
if "you die" in result or "you are dead" in result:
print(result + "\nGAME OVER")
break
else:
print("\n" + result)
if __name__ == '__main__':
+2 -2
View File
@@ -18,7 +18,7 @@ tf.logging.set_verbosity(tf.logging.ERROR)
class SimpleGenerator:
def __init__(self, generate_num=65, temperature=0.4, top_k=40, top_p=0.8):
def __init__(self, generate_num=80, temperature=0.3, top_k=40, top_p=0.8):
self.generate_num=generate_num
self.temp = temperature
self.top_k = top_k
@@ -56,7 +56,7 @@ class SimpleGenerator:
def prompt_replace(self, prompt):
# print("\n\nBEFORE PROMPT_REPLACE:")
# print(repr(prompt))
if prompt[-1] == " ":
if len(prompt) > 0 and prompt[-1] == " ":
prompt = prompt[:-1]
#prompt = second_to_first_person(prompt)
+13 -10
View File
@@ -11,18 +11,13 @@ prompts:
zombies: "You're on top of a building. You look over the city and see roaming undead everywhere. "
action_verbs:
classic: ["You tell", "You use", "You go", "You"]
wanderinginn: "You stumble through the grass, up the hill to the inn. The inn is dark and empty, the ruins of other structures around it. You look around and see "
anything: ["You", "You", "You"]
knight: "You wake up and continue your journey towards Larion Kingdom. You enter a dark forest that you must pass through. "
ctrl_verbs:
non_movement: ["take", "put", "give", "set", "keep", "help", "show", "pay", "read", "start", "stay", "call",
"change", "ask", "open", "look", "make", "say", "tell", "attack", "use", "fight", "scream", "yell"]
movement: ["walk", "go", "run", "move"]
necromancer: "Its been five years since the Great Lich Lord was defeated and now its time to take over again.\nA messenger runs towards you and tells y that your new necromancer lord has already begun laying waste to the lands under your control. You look around at your necromancer captains and ask their advice. "
rooms:
haunted_hospital: ["lobby", "hallway", "parking", "roof", "pharmacy"]
scifi: "You have crashlanded on an some planet. You have a laser pistol and a pack of supplies. You leave your escape pod and see "
contexts:
zombies: "A few months ago a zombie infection broke out. You now are trying to survive on the ruins of what's left in the midst of zombie hordes. "
@@ -31,4 +26,12 @@ contexts:
apocalypse: "Long ago the bombs fell and the world ended. You are one of the few who is still alive. You are trying to survive by scavenging among the ruins of what is left behind. "
classic: "You are a knight in a deep dungeon. "
classic: "You are a knight in a deep dungeon. "
wanderinginn: "You are a young woman and an Innkeeper in a world of magic. "
knight: "You are a knight on a quest to defeat the great dragon of Larion. You are armed with your sword and shield. "
necromancer: "You are a necromancer in a world where undead spell casters rule and fight one another for power and control. "
scifi: "You are a UN space marine with information crucial to the war effort that must get back to Earth. "
+4
View File
@@ -45,6 +45,10 @@ class Story():
latest_result = self.context
mem_ind = self.memory
if len(self.results) < 2:
latest_result += self.story_start
while mem_ind > 0:
if len(self.results) >= mem_ind:
+1 -1
View File
@@ -80,7 +80,7 @@ def cut_trailing_sentence(text):
et_token = text.rfind("<|endoftext|>")
if et_token != -1:
last_punc = min(last_punc, et_token+1)
last_punc = min(last_punc, et_token-1)
act_token = text.find(">")
if act_token != -1: