mirror of
https://github.com/wassname/Clover-Edition.git
synced 2026-09-09 11:13:26 +08:00
Merge branch 'master' of http://github.com/nickwalton/AIDungeon
This commit is contained in:
+2
-9
@@ -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__':
|
||||
|
||||
+12
-6
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user