Aug-14-2020, 01:51 PM
Your
This pseudocode is not at all complete, but gives you the basic idea:
player = False
and the accompanying logic at the start of your loop (lines 21-28) isn't really accomplishing anything at this point. In a game with only two players, you don't necessarily need to use a variable to keep track of whose turn it is. A simple way to handle having one human and one computer player is to include both turns in your main game loop. You get the player's move, apply it, check if the game is over, then do the same for the computer move. Break out when the game ends.This pseudocode is not at all complete, but gives you the basic idea:
while True: print('Number of counters', state) human_move = int(input('Enter your move')) state = state - human_move if state == 1: print('Human wins') break print('Number of counters', state) computer_move = random.randint(1, 3) print('Computer move is', computer_move) state = state - computer_move if state == 1: print('Computer wins') break