Example #1
0
  /**
   * This function simulates a move of the current knight.
   *
   * @param nextPos : Next position of the knight
   * @return: True if position is legal; false otherwise
   */
  protected static boolean makeMove(Move nextPos) // -----need
      {
    if (movesStack.size() >= boardSize * boardSize || !isNextMoveValid(nextPos)) return false;

    Move currentPos = (!movesStack.empty()) ? movesStack.peek() : null;
    movesStack.push(nextPos);
    movesCounter++;

    updatePerformanceCounter(movesCounter);
    if (!tourDraw || !tourRunning) return true;

    if (currentPos != null) {
      // Draw the number of the last position
      colorSquare(currentPos, Color.yellow);
      drawNumber(currentPos, movesStack.size() - 1);
    }
    drawKnight(nextPos);

    // delay(1);

    return true;
  }