Пример #1
0
def pvsnpcgame(premoves=None):
    game = Game()
    #game.print()
    #game.print(mode=3)

    if isinstance(premoves, str):
        for line in premoves.split("\n"):
            line = line.strip()
            if len(line) == 0:
                continue
            print(line)
            game.move(*game.move_from_str(line))
            game.aimove()

    game.printsbs()
    round = 0
    colors = [0, 1]

    try:
        while not game.is_over():
            if game.next_color == 0:
                while True:
                    try:
                        inp = input(">")
                        move = game.move_from_str(inp)
                        result = game.move(*move)
                        if result[0]:
                            break
                        else:
                            print(result)
                    except Exception as e:
                        print(e)
            else:
                result = game.aimove(debug=False)

            #if round % 100 == 0:
            #print(result)
            #game.print()
            #game.print(mode=0)
            #game.print(mode=3)
            game.printsbs()
            if result[0]:
                round += 1
            else:
                notice = "ball out" if result[2] else "e"
                print(result)

    except KeyboardInterrupt:
        pass
    print(game.backup_history())

    print(game.out)
    print(round)
Пример #2
0
def npcvsnpcgame(premoves=None):
    game = Game()
    #game.print()
    #game.print(mode=3)

    if isinstance(premoves, str):
        for line in premoves.split("\n"):
            line = line.strip()
            if len(line) == 0:
                continue
            print(line)
            game.move(*game.move_from_str(line))
            game.aimove()

    game.printsbs()
    round = 0
    colors = [0, 1]

    try:
        while not game.is_over():
            result = game.aimove(debug=False)
            print(game.backup_history())
            #if round % 100 == 0:
            #print(result)
            #game.print()
            #game.print(mode=0)
            #game.print(mode=3)
            game.printsbs()
            if result[0]:
                round += 1
            else:
                notice = "ball out" if result[2] else "e"
                print(result)
    except KeyboardInterrupt:
        pass
    print(game.backup_history())
    print(round)