def checkers():
    t, wn, board = setupBoard()
    gameName = input(
        "Press enter to start a new game, otherwise, type in the name of an old game => "
    )
    if gameName != "":
        currentPlayer, opposingPlayer, currentPlayerTokens, opposingPlayerTokens, forwardRowInc = oldGame(
            t, wn, board, gameName)
    else:
        currentPlayer, opposingPlayer, currentPlayerTokens, opposingPlayerTokens, forwardRowInc = newGame(
            t, wn, board)
    if currentPlayer == "red":
        move = P2.getValidPlayerAction(currentPlayer, currentPlayerTokens,
                                       opposingPlayerTokens, board,
                                       forwardRowInc)
    else:
        move = P1.getValidPlayerAction(currentPlayer, currentPlayerTokens,
                                       opposingPlayerTokens, board,
                                       forwardRowInc)
    while move != "QUIT" and not win(board)[0]:
        while len(move) >= 5:
            move, fromRow, fromCol, toRow, toCol = parseValidMove(move)
            if board[fromRow][fromCol] in ['R', 'B']:
                isKing = True
            else:
                isKing = False
            removeChecker(t, wn, fromRow, fromCol, board)
            drawChecker(t, wn, toRow, toCol, currentPlayer, "gray", board,
                        isKing)
            if abs(fromRow - toRow) > 1:  #Jump is occuring
                removeChecker(t, wn, (fromRow + toRow) // 2,
                              (fromCol + toCol) // 2, board)
        currentPlayer, currentPlayerTokens, opposingPlayer, opposingPlayerTokens, forwardRowInc = switchPlayer(
            currentPlayer)
        if currentPlayer == "red":
            move = P2.getValidPlayerAction(currentPlayer, currentPlayerTokens,
                                           opposingPlayerTokens, board,
                                           forwardRowInc)
        else:
            move = P1.getValidPlayerAction(currentPlayer, currentPlayerTokens,
                                           opposingPlayerTokens, board,
                                           forwardRowInc)
    if move == "QUIT":
        saveGame(board, currentPlayer)
def checkers():
    t, wn, board = setupBoard()
    gameName = input(
        "Press enter to start a new game, otherwise, type in the name of an old game => "
    )
    if gameName != "":
        currentPlayer, opposingPlayer, currentPlayerTokens, opposingPlayerTokens, forwardRowInc = oldGame(
            t, wn, board, gameName)
    else:
        currentPlayer, opposingPlayer, currentPlayerTokens, opposingPlayerTokens, forwardRowInc = newGame(
            t, wn, board)
    boardCopy = copy.deepcopy(board)
    if currentPlayer == "red":
        start = time.time()
        move = P2.getValidPlayerAction(PRINT_DEBUG, currentPlayer,
                                       currentPlayerTokens,
                                       opposingPlayerTokens, boardCopy,
                                       forwardRowInc)
        stop = time.time()
        if PRINT_DEBUG: print("TIME:", stop - start)
        js, mvs = checkMove(board, currentPlayer, currentPlayerTokens,
                            forwardRowInc, opposingPlayerTokens)
        #print("RED MOVES:",mvs)
        #print("RED JUMPS:",js)
        #print("MOVE SELECTED:",move)
        if js != []:
            if move not in js:
                print("You must take a jump!  You lose, red!")
                exit()
        else:
            if move not in mvs and mvs != []:
                print("You must take a jump!  You lose, red!")
                exit()
    else:
        start = time.time()
        move = P1.getValidPlayerAction(PRINT_DEBUG, currentPlayer,
                                       currentPlayerTokens,
                                       opposingPlayerTokens, boardCopy,
                                       forwardRowInc)
        stop = time.time()
        if PRINT_DEBUG: print("TIME:", stop - start)
        js, mvs = checkMove(board, currentPlayer, currentPlayerTokens,
                            forwardRowInc, opposingPlayerTokens)
        #print("BLACK MOVES:",mvs)
        #print("BLACK JUMPS:",js)
        #print("MOVE SELECTED:",move)
        if js != []:
            if move not in js:
                print("You must take a jump!  You lose, black!")
                exit()
        else:
            if move not in mvs and mvs != []:
                print("You must take a jump!  You lose, black!")
                exit()
    while move != "QUIT" and not win(board)[0]:
        while len(move) >= 5:
            move, fromRow, fromCol, toRow, toCol = parseValidMove(move)
            if board[fromRow][fromCol] in ['R', 'B']:
                isKing = True
            else:
                isKing = False
            time.sleep(DELAY)
            removeChecker(t, wn, fromRow, fromCol, board)
            time.sleep(DELAY)
            drawChecker(t, wn, toRow, toCol, currentPlayer, "gray", board,
                        isKing)
            time.sleep(DELAY)
            if abs(fromRow - toRow) > 1:  #Jump is occuring
                removeChecker(t, wn, (fromRow + toRow) // 2,
                              (fromCol + toCol) // 2, board)
        boardCopy = copy.deepcopy(board)
        currentPlayer, currentPlayerTokens, opposingPlayer, opposingPlayerTokens, forwardRowInc = switchPlayer(
            currentPlayer)
        if currentPlayer == "red":
            start = time.time()
            move = P2.getValidPlayerAction(PRINT_DEBUG, currentPlayer,
                                           currentPlayerTokens,
                                           opposingPlayerTokens, boardCopy,
                                           forwardRowInc)
            stop = time.time()
            if PRINT_DEBUG: print("TIME:", stop - start)
            js, mvs = checkMove(board, currentPlayer, currentPlayerTokens,
                                forwardRowInc, opposingPlayerTokens)
            #print("RED MOVES:",mvs)
            #print("RED JUMPS:",js)
            #print("MOVE SELECTED:",move)
            if js != []:
                if move not in js:
                    print("You must take a jump!  You lose, red!")
                    exit()
            else:
                if move not in mvs and mvs != []:
                    print("You must take a jump!  You lose, red!")
                    exit()
        else:
            start = time.time()
            move = P1.getValidPlayerAction(PRINT_DEBUG, currentPlayer,
                                           currentPlayerTokens,
                                           opposingPlayerTokens, boardCopy,
                                           forwardRowInc)
            stop = time.time()
            if PRINT_DEBUG: print("TIME:", stop - start)
            js, mvs = checkMove(board, currentPlayer, currentPlayerTokens,
                                forwardRowInc, opposingPlayerTokens)
            #print("BLACK MOVES:",mvs)
            #print("BLACK JUMPS:",js)
            #print("MOVE SELECTED:",move)
            if js != []:
                if move not in js:
                    print("You must take a jump!  You lose, black!")
                    exit()
            else:
                if move not in mvs and mvs != []:
                    print("You must take a jump!  You lose, black!")
                    exit()
    if move == "QUIT":
        saveGame(board, currentPlayer)