예제 #1
0
파일: main.py 프로젝트: Oscar-Rydh/AiLab1
game = GameState()
game.initialize()
while (True):
    coordinates = [1]
    while (len(coordinates) != 2):
        if (len(game.validMoves()) == 0):
            print("")
            if (game.stateValue() < 0):
                print('Human Won!!')
            elif (game.stateValue() > 0):
                print('Computer Won!!')
            else:
                print('Its a draw!')
            sys.exit()
        if (game.getPlayerOneTurn()):
            game.printGameState()
            coordinates = input(
                'Where do you want to place your brick? (row col): \n').split(
                    ' ')
            while len(coordinates) is not 2:
                print("Input two values")
                coordinates = input(
                    'Where do you want to place your brick? (row col): \n'
                ).split(' ')
            x = int(coordinates[0]) - 1
            y = int(coordinates[1]) - 1
            while not game.placeDisk(Move(x, y)):
                print("Invalid input, try again")
                coordinates = input(
                    'Where do you want to place your brick? (row col): \n'
                ).split(' ')