示例#1
0
文件: main.py 项目: chromakode/josie
def run_system_world():
	# Switch to the system world temporarily, retaining the old world state.
	game.currentworld = game.world
	game.world = world.load(load_world("system"))
	
	io.output("--- Entering System World ---")
	game.world.protagonist.globalcommands = game.currentworld.protagonist.globalcommands
	game.world.protagonist.commands["look"]()
	
	while True:
		print
		try:
			cmd = io.input("> ")
		except (KeyboardInterrupt, EOFError):
			game.world = game.currentworld
			save_and_quit()
			
		if cmd in ("done", "leave"):
			break
		game.world.protagonist.do_command(cmd)
	
	io.output("--- Leaving System World ---")
	game.world = game.currentworld
	game.currentworld = None
	game.world.protagonist.commands["look"]()
示例#2
0
文件: main.py 项目: chromakode/josie
def mainloop():
	while game.playing:
		print
		try:
			cmd = io.input("> ")
		except (KeyboardInterrupt, EOFError):
			save_and_quit()
		
		game.world.protagonist.do_command(cmd)
示例#3
0
import io_basic as io
from library import npc

mybot = npc.MarkovNPC("MyBot", "MarkovGen Dummy Bot")
mybot.vars["markov"] = dict()

io.output("""\
Markov Chain Generator
Use this tool to create brains for Markov chain NPCs. Please enter sentences to "teach" the bot; do note that due to the nature of Markov bots, these words will be mashed up and rearranged once enough sentences have been entered. Shoot for at least 15-25 sentences. 

At any time, a blank line or "!say ___" will simulate speaking to the bot. Type "!quit" to exit (and output the Markov chains).
""", fast=True)

while 1:
	sentence = io.input("Add a sentence: ")
	
	if sentence == "!quit":
		break
	if sentence[0:4] == "!say" or sentence == "":
		if mybot.vars["markov"]:
			if sentence != "":
				said = sentence[4:]
			else:
				said = ""
			io.output("The bot says: " + mybot.walk_chain(said=said))
			continue
		else:
			io.output("Please add a sentence to the bot.")
			continue