Ejemplo n.º 1
0
def main(argv):

    size = 0
    limit = -1
    ordering = False
    caching = False
    minimax = False
    agent1 = None
    agent2 = None

    try:
        opts, args = getopt.getopt(
            argv, "hcmol:d:a:b:", ["limit=", "dimension=", "agent1=", "agent2="]
        )
    except getopt.GetoptError:
        print(
            "othello_gui.py -d <dimension> [-a <agentA> -b <agentB> -l <depth-limit> -c -o -m]"
        )
        sys.exit(2)
    for opt, arg in opts:
        if opt == "-h":
            print(
                "othello_gui.py -d <dimension> -a <agentA> [-b <agentB> -l <depth-limit> -c -o]"
            )
            sys.exit()
        elif opt in ("-d", "--dimension"):
            size = int(arg)
        elif opt in ("-a", "--agentA"):
            agent1 = arg
        elif opt in ("-b", "--agentB"):
            agent2 = arg
        elif opt in ("-c", "--caching"):
            caching = True
        elif opt in ("-m", "--minimax"):
            minimax = True
        elif opt in ("-o", "--ordering"):
            ordering = True
        elif opt in ("-l", "--limit"):
            limit = int(arg)

    if size <= 0:  # if no dimension provided
        print("Please provide a board size.")
        print(
            "othello_gui.py -d <dimension> [-a <agentA> -b <agentB> -l <depth-limit> -c -o]"
        )
        sys.exit(2)

    if agent1 != None and agent2 != None and size > 0:
        p1 = AiPlayerInterface(agent1, 1, limit, minimax, caching, ordering)
        p2 = AiPlayerInterface(agent2, 2, limit, minimax, caching, ordering)
    elif agent1 != None and size > 0:
        p1 = Player(1)
        p2 = AiPlayerInterface(agent1, 2, limit, minimax, caching, ordering)
    else:
        p1 = Player(1)
        p2 = Player(2)

    game = OthelloGameManager(size)
    gui = OthelloGui(game, p1, p2)
    gui.run()
Ejemplo n.º 2
0
def main():
    if len(sys.argv) == 3:
        p1 = AiPlayerInterface(sys.argv[1], 1)
        p2 = AiPlayerInterface(sys.argv[2], 2)
    elif len(sys.argv) == 2:
        p1 = Player(1)
        p2 = AiPlayerInterface(sys.argv[1], 2)
    else:
        p1 = Player(1)
        p2 = Player(2)
    game = OthelloGameManager(dimension=8)
    gui = OthelloGui(game, p1, p2)
    gui.run()
Ejemplo n.º 3
0
            except AiTimeoutError:
                print("{} ({}) timed out!".format(player_obj.name, color))
                print("FINAL: {} (dark) {}:{} {} (light)".format(
                    player_obj.name, p1score, p2score, player2.name))
                #player1.kill(game)
                #player2.kill(game)
                serverSocket.close()
                break


if __name__ == "__main__":

    if len(sys.argv) == 4:
        game = OthelloGameManager(dimension=int(sys.argv[1]))
        p1 = AiPlayerInterface(sys.argv[2], 1)
        p2 = AiPlayerInterface(sys.argv[3], 2)
    elif len(sys.argv) == 3:
        game = OthelloGameManager(dimension=int(sys.argv[1]))
        p1 = Player(1)
        p2 = AiPlayerInterface(sys.argv[2], 2)
    elif len(sys.argv) == 2:
        p1 = Player(1)
        p2 = Player(2)
        game = OthelloGameManager(dimension=int(sys.argv[1]))
    else:
        p1 = Player(1)
        p2 = Player(2)
        game = OthelloGameManager(dimension=8)
    #gameManager = OthelloGameManager(game, p1, p2)
    play_game(game, p1, p2)