diff --git a/console_play.py b/console_play.py index 1424be1..3896f7a 100644 --- a/console_play.py +++ b/console_play.py @@ -28,21 +28,14 @@ def play_unconstrained(): if action != "": action = action.strip() - action = action[0].lower() + action[1:] - - if action[-1] == "." or action[-1] == "?" or action[-1] == "!": - action = action[:-1] - if "you " == action.lower()[0:4]: - action = action[4:] - if "i " == action.lower()[0:2]: - action = action[2:] + action = action[0].upper() + action[1:] action = "\n> " + action + ".\n" action = remove_profanity(action) #action = first_to_second_person(action) result = story_manager.act(action) - print("\n\n" + action + result) + print(result) if __name__ == '__main__': diff --git a/story/story_manager.py b/story/story_manager.py index db60ae9..78c646a 100644 --- a/story/story_manager.py +++ b/story/story_manager.py @@ -23,6 +23,7 @@ class Story(): if game_state is None: game_state = dict() self.game_state = game_state + self.memory = 3 def initialize_from_json(self, json_string): @@ -41,12 +42,17 @@ class Story(): self.results.append(story_block) def latest_result(self): - if len(self.results) >= 2: - return self.context + self.actions[-2] + self.results[-2] + self.actions[-1] + self.results[-1] - elif len(self.results) >= 1: - return self.context + self.actions[-1] + self.results[-1] - else: - return self.context + self.story_start + + latest_result = self.context + mem_ind = self.memory + while mem_ind > 0: + + if len(self.results) >= mem_ind: + latest_result += (self.actions[-mem_ind] + self.results[-mem_ind]) + + mem_ind -= 1 + + return latest_result def __str__(self): story_list = [self.story_start]