mirror of
https://github.com/wassname/Clover-Edition.git
synced 2026-09-09 11:13:26 +08:00
update
This commit is contained in:
+6
-7
@@ -41,13 +41,12 @@ def play_unconstrained():
|
||||
|
||||
def play_constrained():
|
||||
print("\n")
|
||||
generator = WebGenerator(CRED_FILE)
|
||||
#generator = CTRLGenerator()
|
||||
#generator = WebGenerator(CRED_FILE)
|
||||
generator = CTRLGenerator()
|
||||
story_start = "haunted"
|
||||
verbs_key = "anything"
|
||||
prompt = get_story_start(story_start)
|
||||
story_manager = CTRLStoryManager(generator)
|
||||
story_manager.start_new_story(prompt, action_verbs_key=verbs_key)
|
||||
story_manager.start_new_story(prompt)
|
||||
|
||||
console_print(str(story_manager.story))
|
||||
possible_actions = story_manager.get_possible_actions()
|
||||
@@ -70,8 +69,8 @@ def play_constrained():
|
||||
|
||||
def play_cached():
|
||||
generator = WebGenerator(CRED_FILE)
|
||||
story_manager = CachedStoryManager(generator, 0, 0, CRED_FILE)
|
||||
story_manager.start_new_story()
|
||||
story_manager = CachedStoryManager(generator, CRED_FILE)
|
||||
story_manager.start_new_story(get_story_start("classic"), 0)
|
||||
|
||||
console_print(str(story_manager.story))
|
||||
possible_actions = story_manager.get_possible_actions()
|
||||
@@ -90,7 +89,7 @@ def play_cached():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
play_unconstrained()
|
||||
play_constrained()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -101,17 +101,18 @@ class UnconstrainedStoryManager(StoryManager):
|
||||
block = story_replace(block)
|
||||
return block
|
||||
|
||||
|
||||
class ConstrainedStoryManager(StoryManager):
|
||||
|
||||
def __init__(self, generator, action_verbs_key="classic"):
|
||||
self.generator = generator
|
||||
super().__init__(generator)
|
||||
self.action_phrases = get_action_verbs(action_verbs_key)
|
||||
|
||||
def start_new_story(self, story_prompt):
|
||||
super().start_new_story(story_prompt)
|
||||
self.story.possible_action_results = self.get_action_results()
|
||||
|
||||
return story.story_start
|
||||
return self.story.story_start
|
||||
|
||||
def load_story(self, story, from_json=False):
|
||||
story_string = super().load_story(story, from_json=from_json)
|
||||
@@ -167,7 +168,7 @@ class CTRLStoryManager(ConstrainedStoryManager):
|
||||
used_verbs = []
|
||||
results = []
|
||||
for phrase in self.action_phrases:
|
||||
options = {}
|
||||
options = dict()
|
||||
options["used_verbs"] = used_verbs
|
||||
result = self.generate_action_result(self.story_context(), phrase, options=options)
|
||||
|
||||
@@ -184,7 +185,7 @@ class CachedStoryManager(ConstrainedStoryManager):
|
||||
super().__init__(generator, action_verbs_key=action_verbs_key)
|
||||
self.cacher = cacher(credentials_file)
|
||||
|
||||
def start_new_story(self, prompt, seed):
|
||||
def start_new_story(self, prompt, seed=0):
|
||||
|
||||
result = self.cacher.retrieve_from_cache(seed, [], "story")
|
||||
if result is not None:
|
||||
|
||||
Reference in New Issue
Block a user