mirror of
https://github.com/wassname/Clover-Edition.git
synced 2026-09-10 11:40:48 +08:00
update
This commit is contained in:
+11
-7
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user