Beispiel #1
0
def main():
    game = Game(1, 1, debug=True)
    status = Game.GAME_CONTINUES
    while status == Game.GAME_CONTINUES:
        print game.board
        try:
            input = raw_input('cmd: ')
            args = input.split(' ')
            if args[0] == 'T':
                ticks = int(args[1])
                for i in xrange(ticks):
                    status = game.tick()
                    if status != Game.GAME_CONTINUES:
                        break
            elif args[0] == 'M':
                from_row, from_col, to_row, to_col = int(args[1]), int(
                    args[2]), int(args[3]), int(args[4])
                piece = game.board.get_piece_by_location(from_row, from_col)
                valid = game.move(piece.id, piece.player, to_row, to_col)
                if not valid:
                    print 'Invalid move!'
        except KeyboardInterrupt:
            break
        except Exception, e:
            print 'Error: ' + str(e)
Beispiel #2
0
        import yappi
        yappi.set_clock_type('wall')
        yappi.start()

    bot = get_bot('advanced')
    game = Game(Speed('standard'), {})
    for i in xrange(10000):
        if game.finished:
            break

        move = bot.get_move(game, 1, random.randint(0, 9999))
        if move:
            piece, row, col = move
            if not game.move(piece.id, piece.player, row, col):
                print piece, row, col

        move = bot.get_move(game, 2, random.randint(0, 9999))
        if move:
            piece, row, col = move
            if not game.move(piece.id, piece.player, row, col):
                print piece, row, col

        game.tick()

        if i % 100 == 0:
            print i

    if profile:
        yappi.stop()
        yappi.get_func_stats().print_all()