def checkers(CB, bob, PlayerB, PlayerR, Bwin, Rwin, totalPlayed): #junk=input("Hey hey hey") imp.reload(P1) imp.reload(P2) player = readCheckerFile(CB) print(player, "goes first") SIZE = 60 if VISIBLE: fillCheckerBoard(bob, SIZE, CB) labelGameStats(bob, SIZE, PlayerB, PlayerR, Bwin, Rwin, totalPlayed) move = '' numChecks = [0, 0, 0] while move != 'exit' and not win(CB, numChecks)[0]: possibles = getPossibles(CB, player) if player == "red": oppPlayer = "black" move = P2.automatedMove(CB, player) else: oppPlayer = "red" move = P1.automatedMove(CB, player) countBadMoves = 1 #Until a valid move or exceeds allowed number of bad move trys while ((move != "exit") and (not (validMove(CB, move, player)))) and (countBadMoves != 3): countBadMoves += 1 if player == "red": oppPlayer = "black" move = P2.automatedMove(CB, player) else: oppPlayer = "red" move = P1.automatedMove(CB, player) #terminate due to bad moves or exit entered (and save state) if countBadMoves == 3 or move == "exit": if countBadMoves == 3: print("Game terminated because player ", player, " refused to make a valid move!") else: writeGameState(CB, player) return oppPlayer #All good - make move! makeMove(bob, CB, move, player, SIZE, possibles) #showBoard(CB) player = switchPlayers(player) return win(CB, numChecks)[1]