This commit is contained in:
Nick committed 2019-09-19 22:30:27 -06:00
1 parent ae7ec784ff
commit 8902c1f0ed
3 files changed
+18 -10

No files matched your search

+11 -7
View File
@@ -4,23 +4,27 @@ from google.cloud import storage
import json
from story.story_manager import *
from generator.web.web_generator import *
from generator.ctrl.ctrl_generator import *
#from generator.ctrl.ctrl_generator import *
import tensorflow as tf
import textwrap
CRED_FILE = "./AI-Adventure-2bb65e3a4e2f.json"
prompt = "You enter a dungeon with your trusty sword and shield. You are searching for the evil necromancer who killed your family. You've heard that he resides at the bottom of the dungeon, guarded by legions of the undead. You enter the first door and see"
prompt = "You enter a dungeon with your trusty sword and shield. You are searching for the evil necromancer who killed your family. You've heard that he resides at the bottom of the dungeon, guarded by legions of the undead. You enter the first door and see "
# Set the key
def console_print(str):
LINE_WIDTH=80
print((textwrap.fill(str, 80)))
def console_print(str, pycharm=False):
if pycharm:
LINE_WIDTH=80
print((textwrap.fill(str, LINE_WIDTH)))
else:
print(str)
def play_unconstrained():
generator = CTRLGenerator()
#generator = WebGenerator(CRED_FILE)
#generator = CTRLGenerator()
generator = WebGenerator(CRED_FILE)
story_manager = UnconstrainedStoryManager(generator, prompt)
console_print(str(story_manager.story))
+4
View File
@@ -138,6 +138,10 @@ class CTRLGenerator():
def generate(self, prompt):
if prompt[-1] != " ":
prompt = prompt + " "
prompt = second_to_first_person(prompt)
prompt = self.control_code + prompt
+3 -3
View File
@@ -27,9 +27,9 @@ class Story():
def latest_result(self):
if len(self.results) > 1:
return self.results[-2] + self.action[-1] + self.results[-1]
elif len(self.results) > 0:
return self.results[-1]
return self.results[-2] + self.actions[-1] + self.results[-1]
elif len(self.results) == 1:
return self.story_start + self.results[-1]
else:
return self.story_start