Enrollments closing soon for Post Graduate Certificate Program in Applied Data Science & AI By IIT Roorkee | 3 Seats Left

  Apply Now

Project- Game of Tic Tac Toe with Python

11 / 16

Tic Tac Toe with Python - How will the human player move

Now we will write a function that will define how a human player will make their moves in this game.

INSTRUCTIONS
  • Define the function human_move as shown below, this function takes 2 arguments, board, and human respectively:

    def <<your code goes here>>(board, <<your code goes here>>):
        legal = legal_moves(board)
        move = None
        while move not in legal:
            move = ask_number("Where will you move? (0-8): ", 0, NUM_SQUARES)
            if move not in legal:
                print("\nUn oh, looks like that square is already occupied. Choose another one.\n")
        print("Fine...")
        return move
    
See Answer

No hints are availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...