def main():
    connect_four = ConnectFourBoard()
    menu_choice = 1
    while menu_choice == 1:
        os.system(['clear', 'cls'][os.name == 'nt'])
        # start the game
        start_choice = -1
        while start_choice != 1 and start_choice != 2:
            print("Start")
            print("1) Move first")
            print("2) Move second")
            start_choice = int(raw_input("choice : "))
            if start_choice != 1 and start_choice != 2:
                print("This option does not exist")
                print("\n\n\n")
        connect_four.start_new(start_choice)
        # menu
        print("Menu")
        print("1) Play again")
        print("2) Quit")
        menu_choice = int(raw_input("choice : "))
示例#2
0
    else:
        raise ValueError

try:
    print('Player 1:')
    current_player = get_player(Color.red)
    print('Player 2:')
    next_player = get_player(Color.black)

    print('Board dimensions')
    print('----------------')
    print('Width:  ', end = '')
    width = int(input())
    print('Height: ', end = '')
    height = int(input())
    print('Goal:   ', end = '')
    goal = int(input())

    board = ConnectFourBoard(width=width, height=height, goal=goal)

    while not board.is_game_over:
        print(board)
        board.drop_piece(current_player.color, current_player.get_move(board))
        current_player, next_player = next_player, current_player

    print(board)
    print('Winner:', board.winner)

except Exception as e:
    print(e)