import tensorflow as tf import framework as fw import data_loader as dl import model.model_base as mb import model.model_rl as mr FLAGS = tf.flags.FLAGS if __name__ == '__main__': fw.init() model = mr.model_rl if '_rl' in FLAGS.se else mb.model framework = fw.framework(dl.json_file_data_loader(), dl.json_file_data_loader(dl.file_data_loader.TEST_PREFIX, dl.file_data_loader.MODE_ENTPAIR_BAG, shuffle=False)) with tf.variable_scope(FLAGS.model_name, reuse=tf.AUTO_REUSE): framework.train(model)
# Keys when game is running: # ESC - leaves the game # SPACE - advances player one step # RETURN/ENTER - moves player all way to the exit # # If player leaves map/screen it is game over # If player moves twice more time than there are squares on the map it is game over # Logic to move player around the map goes here: if player.x < exit.x: return Right return Left def turn(direction): if direction == Down: return Left if direction == Left: return Up if direction == Up: return Right return Down framework.init(nextPlayerPosition) framework.mainLoop()
import json import numpy as np import os import tensorflow as tf import framework as fw import data_loader as dl import model.model_base as mb import model.model_rl as mr FLAGS = tf.flags.FLAGS if __name__ == '__main__': fw.init(is_training=False) model = mr.model_rl if 'rl' in FLAGS.se else mb.model framework = fw.framework(test_data_loader=dl.json_file_data_loader( dl.file_data_loader.TEST_PREFIX, dl.file_data_loader.MODE_ENTPAIR_BAG, shuffle=False)) with tf.variable_scope(FLAGS.model_name, reuse=tf.AUTO_REUSE): auc, pred_result, output, acc_total, acc_not_na = framework.test( model, model_name=FLAGS.model_name, return_result=True) with open( os.path.join(FLAGS.test_result_dir, FLAGS.model_name + "_pred.json"), 'w') as of: json.dump(pred_result, of) np.save(os.path.join(FLAGS.test_result_dir, FLAGS.model_name + "_out.npy"), output) with open(
#while world_intro.loop(): # events.trigger_event('cleanup') world_menu.create() while world_menu.loop(): events.trigger_event('cleanup') #world_hire.create() #while world_hire.loop(): # events.trigger_event('cleanup') world_strategy.create() while world_strategy.loop(): events.trigger_event('cleanup') framework.shutdown() if __name__ == '__main__': framework.init(debug='--debug' in sys.argv) framework.events.register_event('boot', words.boot) if '--debug' in sys.argv: cProfile.run('framework.run(main)', 'profile.dat') else: framework.run(main)
# breadcrumb[0] = first (original) direction player has gone to from that cell # Keys when game is running: # ESC - leaves the game # SPACE - advances player one step # RETURN/ENTER - moves player all way to the exit # # If player leaves map/screen it is game over # If player moves twice more time than there are squares on the map it is game over # Logic to move player around the map goes here: if player.x < exit.x: return Right return Left def turn(direction): if direction == Down: return Left if direction == Left: return Up if direction == Up: return Right return Down framework.init(nextPlayerPosition) framework.mainLoop()
def init(): framework.init() currentlevel.level()
# events.trigger_event('cleanup') world_menu.create() while world_menu.loop(): events.trigger_event('cleanup') #world_hire.create() #while world_hire.loop(): # events.trigger_event('cleanup') world_strategy.create() while world_strategy.loop(): events.trigger_event('cleanup') framework.shutdown() if __name__ == '__main__': framework.init(debug='--debug' in sys.argv) framework.events.register_event('boot', words.boot) if '--debug' in sys.argv: cProfile.run('framework.run(main)', 'profile.dat') else: framework.run(main)
for name, f in filters.items(): env.filters[name] = f add_template(env) def datetime_filter(t): delta = int(time.time() - t) if delta < 60: return u'1分钟前' if delta < 3600: return u'%s分钟前' % (delta // 60) if delta < 86400: return u'%s小时前' % (delta // 3600) if delta < 604800: return u'%s天前' % (delta // 86400) dt = datetime.fromtimestamp(t) return u'%s年%s月%s日' % (dt.year, dt.month, dt.day) def init_database(): db.create_engine(**db_config) from config import get_configs configs = get_configs() server_config = configs['server'] db_config = configs['db'] session_config = configs['session'] init(server_config['host'], server_config['port']) init_database() init_jinja2(filters=dict(datetime=datetime_filter)) add_routes('handlers') start()