Example #1
0
    p1 = Monkey(1) if do_human else Player(1)
    p2 = Monkey(2)  # AI - can do play_move() and gen_move()
    p1.logger = logger
    p2.logger = logger

    # create engine
    engine = Engine()

    # create board of default size 19
    board = Board(19)

    # attach everything
    engine.board = board
    engine.set_players(p1, p2)
    engine.logger = logger
    p1.engine = engine
    p2.engine = engine

    # create gtp_parser
    gtp = GTP(engine, logger, in_file)

    # start reading commands from in_file
    if not do_human:
        gtp.run()
    else:
        players = ["black", "white"]
        p = 0
        while True:
            engine.showboard()
            engine.genmove(players[p])
            p = (p + 1) % 2