takeback()
    {
        if (this.#totalMoves > 0)
        {
            console.assert(this.gameLog.length > 0);
            var lastMove = this.gameLog.pop(); //pop the last move from the log
            var lastRow = lastMove.row;
            var lastCol = lastMove.col;

            console.assert(this.board[lastRow][lastCol] !== EMPTY);

            this.board[lastRow][lastCol] = EMPTY; //turn last cell back to EMPTY state
            this.#whiteMoves = !this.#whiteMoves; //change side
            this.#totalMoves--;
            this.#turnsRemaining ++;
            this.outcome = ONGOING; //if the game was over before the last move, it would not be possible to get here
            this.debugBoard = this.display();

            return true;
        }

        return false;
    }
/**
     * Takes back the last move played and returns true if succeeded
     */
Takes back the last move played and returns true if succeeded
Takes back the last move played and returns true if succeeded
takeback()
    {
        if (this.#totalMoves > 0)
        {
            console.assert(this.gameLog.length > 0);
            var lastMove = this.gameLog.pop(); 
            var lastRow = lastMove.row;
            var lastCol = lastMove.col;
            console.assert(this.board[lastRow][lastCol] !== EMPTY);
            this.board[lastRow][lastCol] = EMPTY; 
            this.#whiteMoves = !this.#whiteMoves; 
            this.#totalMoves--;
            this.#turnsRemaining ++;
            this.outcome = ONGOING; 
            this.debugBoard = this.display();
            return true;
        }
        return false;
    }
takeback ( ) { if ( this . #totalMoves > 0 ) { console . assert ( this . gameLog . length > 0 ) ; var lastMove = this . gameLog . pop ( ) ; var lastRow = lastMove . row ; var lastCol = lastMove . col ; console . assert ( this . board [ lastRow ] [ lastCol ] !== EMPTY ) ; this . board [ lastRow ] [ lastCol ] = EMPTY ; this . #whiteMoves = ! this . #whiteMoves ; this . #totalMoves -- ; this . #turnsRemaining ++ ; this . outcome = ONGOING ; this . debugBoard = this . display ( ) ; return true ; } return false ; }
Takes back the last move played and returns true if succeeded
Takes back the last move played and returns true if succeeded
//pop the last move from the log
 //turn last cell back to EMPTY state
 //change side
 //if the game was over before the last move, it would not be possible to get here
