From c63f7e051ad92d460bb39f0c3794eda05eed92f6 Mon Sep 17 00:00:00 2001 From: Nick Walton Date: Mon, 2 Dec 2019 07:41:48 -0700 Subject: [PATCH] Develop (#11) * adds saving and loading * fixed some cmd issues * fixed some cmd issues * fixed capitalization issue * smallupdate * update * update * dev changes * more testing * more dev fixes * dragon story * dragon story * adding ai dm mode * dm fix * dm * dm * Gcloudstoragestuff * fixed loading issues * upped memory --- play.py | 2 +- story/story_manager.py | 2 +- story/utils.py | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/play.py b/play.py index ef4b38c..3dfe05a 100644 --- a/play.py +++ b/play.py @@ -93,7 +93,7 @@ def play_aidungeon_2(): story_manager.start_new_story(prompt, context=context, upload_story=upload_story) print("\n") - console_print(context + str(story_manager.story)) + console_print(str(story_manager.story)) while True: tcflush(sys.stdin, TCIFLUSH) action = input("> ") diff --git a/story/story_manager.py b/story/story_manager.py index 8ba1f13..ff0566f 100644 --- a/story/story_manager.py +++ b/story/story_manager.py @@ -28,7 +28,7 @@ class Story(): if game_state is None: game_state = dict() self.game_state = game_state - self.memory = 8 + self.memory = 20 def __del__(self): if self.upload_story: diff --git a/story/utils.py b/story/utils.py index c0b40c6..686e4f7 100644 --- a/story/utils.py +++ b/story/utils.py @@ -96,17 +96,18 @@ def cut_trailing_action(text): def cut_trailing_sentence(text): text = standardize_punctuation(text) last_punc = max(text.rfind('.'), text.rfind("!"), text.rfind("?")) + if last_punc <= 0: + last_punc = len(text)-1 et_token = text.rfind("<|endoftext|>") - if et_token != -1: + if et_token > 0: last_punc = min(last_punc, et_token-1) act_token = text.find(">") - if act_token != -1: + if act_token > 0: last_punc = min(last_punc, act_token-1) - - if last_punc > 0: - text = text[0:last_punc+1] + + text = text[:last_punc+1] text = cut_trailing_quotes(text) text = cut_trailing_action(text)