diff --git a/console_play.py b/console_play.py index 609e665..899929e 100644 --- a/console_play.py +++ b/console_play.py @@ -4,23 +4,27 @@ from google.cloud import storage import json from story.story_manager import * from generator.web.web_generator import * -from generator.ctrl.ctrl_generator import * +#from generator.ctrl.ctrl_generator import * import tensorflow as tf import textwrap CRED_FILE = "./AI-Adventure-2bb65e3a4e2f.json" -prompt = "You enter a dungeon with your trusty sword and shield. You are searching for the evil necromancer who killed your family. You've heard that he resides at the bottom of the dungeon, guarded by legions of the undead. You enter the first door and see" +prompt = "You enter a dungeon with your trusty sword and shield. You are searching for the evil necromancer who killed your family. You've heard that he resides at the bottom of the dungeon, guarded by legions of the undead. You enter the first door and see " # Set the key -def console_print(str): - LINE_WIDTH=80 - print((textwrap.fill(str, 80))) +def console_print(str, pycharm=False): + if pycharm: + LINE_WIDTH=80 + + print((textwrap.fill(str, LINE_WIDTH))) + else: + print(str) def play_unconstrained(): - generator = CTRLGenerator() - #generator = WebGenerator(CRED_FILE) + #generator = CTRLGenerator() + generator = WebGenerator(CRED_FILE) story_manager = UnconstrainedStoryManager(generator, prompt) console_print(str(story_manager.story)) diff --git a/generator/ctrl/ctrl_generator.py b/generator/ctrl/ctrl_generator.py index 52810a7..fec60f1 100644 --- a/generator/ctrl/ctrl_generator.py +++ b/generator/ctrl/ctrl_generator.py @@ -138,6 +138,10 @@ class CTRLGenerator(): def generate(self, prompt): + + if prompt[-1] != " ": + prompt = prompt + " " + prompt = second_to_first_person(prompt) prompt = self.control_code + prompt diff --git a/story/story_manager.py b/story/story_manager.py index 8b909e0..c30a6ca 100644 --- a/story/story_manager.py +++ b/story/story_manager.py @@ -27,9 +27,9 @@ class Story(): def latest_result(self): if len(self.results) > 1: - return self.results[-2] + self.action[-1] + self.results[-1] - elif len(self.results) > 0: - return self.results[-1] + return self.results[-2] + self.actions[-1] + self.results[-1] + elif len(self.results) == 1: + return self.story_start + self.results[-1] else: return self.story_start