Exemple #1
0
def main():
    pid = os.getpid()
    LOG_FORMAT = str(pid) + ':%(levelname)s:%(asctime)s: %(message)s'

    logging.basicConfig(format=LOG_FORMAT, level=logging.DEBUG)
    logging.debug("Start dummy backend...")

    try:
        while True:
            logging.debug("Wait for game update...")
            game = backend.wait_for_game_update()

            if not game:
                logging.debug("Game is over!")
                return

            logging.debug('Game: [%s]', game.dumps())
            move = choose_random_move(game.board())

            if not backend.set_move(move):
                logging.error("Impossible set move!")
                return

            logging.debug('Random move: %s', move)

    except:
        logging.error('Error!', exc_info=True, stack_info=True)
Exemple #2
0
def main():
    logging.basicConfig(filename='dummy.log', level=logging.DEBUG)
    logging.debug("Start dummy backend...")


    env = RenjuTEST(1, 'me')
    tree = UCT(env, model, 'kn' if random.randint(0,1) == 0 else 'neuron')
    st = 0
    
    try:
        while True:
            logging.debug("Wait for game update...")
            game = backend.wait_for_game_update()
            pos = game.positions()

            if (len(pos) > 0):
                env.in_step(conv_tup(pos[-1]))
                st += 1
			
			
            tree = UCT(env, model, 'kn' if random.randint(0,1) == 0 else 'neuron')
            tree_act = tree.do_mcst(time_for_search)

            if st == 0:
                tree_act = 112
            st += 1
            env.in_step(tree_act)


            tree_act = inverse_convert(tree_act)
            backend.move(tree_act)

    except:
        logging.debug('Error!', exc_info=True, stack_info=True)
Exemple #3
0
def main():
    logging.basicConfig(filename='dummy.log', level=logging.DEBUG)
    logging.debug("Start dummy backend...")

    try:
        while True:
            logging.debug("Wait for game update...")
            game = backend.wait_for_game_update()
            logging.debug('Board:\n' + str(game.board()))

            move = choose_random_move(game.board())
            backend.move(move)
            logging.debug('make move: ' + move)
    except:
        logging.error('Error!', exc_info=True, stack_info=True)