mirror of
https://github.com/wassname/Clover-Edition.git
synced 2026-09-09 11:13:26 +08:00
refactored
This commit is contained in:
@@ -90,6 +90,35 @@ def play_cached():
|
||||
|
||||
console_print(result)
|
||||
|
||||
def play_cached_hospital():
|
||||
print("\n")
|
||||
generator = CTRLGenerator()
|
||||
story_start = "haunted"
|
||||
prompt = get_story_start(story_start)
|
||||
story_manager = CTRLStoryManager(generator)
|
||||
story_manager.enable_caching(CRED_FILE, bucket_name="haunted-hospital")
|
||||
|
||||
story_manager.start_new_story(prompt)
|
||||
|
||||
console_print("\n")
|
||||
console_print(str(story_manager.story))
|
||||
possible_actions = story_manager.get_possible_actions()
|
||||
while (True):
|
||||
console_print("\nOptions:")
|
||||
for i, action in enumerate(possible_actions):
|
||||
console_print(str(i) + ") " + action)
|
||||
|
||||
result = None
|
||||
while (result == None):
|
||||
action_choice = input("Which action do you choose? ")
|
||||
if action_choice is "print story":
|
||||
print(story_manager.story)
|
||||
continue
|
||||
print("\n")
|
||||
result, possible_actions = story_manager.act(action_choice)
|
||||
|
||||
console_print(result)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
play_unconstrained()
|
||||
|
||||
@@ -298,6 +298,7 @@ class CTRLGenerator():
|
||||
|
||||
def generate(self, prompt, options=None):
|
||||
prompt = self.prompt_replace(prompt)
|
||||
print("PROMPT: \n", prompt)
|
||||
|
||||
if options is None: options = dict()
|
||||
if "used_verbs" not in options:
|
||||
@@ -331,6 +332,5 @@ class CTRLGenerator():
|
||||
|
||||
token_num += 1
|
||||
|
||||
print("PROMPT: \n", prompt)
|
||||
print("RESULT: \n", result)
|
||||
return self.result_replace(result)
|
||||
|
||||
Reference in New Issue
Block a user