mirror of
https://github.com/wassname/Clover-Edition.git
synced 2026-09-09 11:13:26 +08:00
added print wrapping
This commit is contained in:
+9
-4
@@ -2,10 +2,15 @@ from story.story_manager import *
|
||||
# from generator.web.web_generator import *
|
||||
# from generator.ctrl.ctrl_generator import *
|
||||
from generator.gpt2.gpt2_generator import *
|
||||
import textwrap
|
||||
|
||||
CRED_FILE = "./AI-Adventure-2bb65e3a4e2f.json"
|
||||
|
||||
|
||||
def console_print(text, width=75):
|
||||
print(textwrap.fill(text, width))
|
||||
|
||||
|
||||
def play_unconstrained():
|
||||
generator = GPT2Generator()
|
||||
prompt = get_story_start("knight")
|
||||
@@ -14,8 +19,8 @@ def play_unconstrained():
|
||||
story_manager.start_new_story(prompt, context=context)
|
||||
|
||||
print("\n")
|
||||
print(context)
|
||||
print(str(story_manager.story))
|
||||
console_print(context)
|
||||
console_print(str(story_manager.story))
|
||||
while True:
|
||||
action = input("> ")
|
||||
|
||||
@@ -30,10 +35,10 @@ def play_unconstrained():
|
||||
|
||||
result = story_manager.act(action)
|
||||
if player_died(result):
|
||||
print(result + "\nGAME OVER")
|
||||
console_print(result + "\nGAME OVER")
|
||||
break
|
||||
else:
|
||||
print(result)
|
||||
console_print(result)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user