I am implementing a chess game. I am aware of the rules but I have not played it much. I need clarification on a small point.
Suppose a player legally moves a piece from square A to square B. Consider the path this piece followed during this move. Can it be different based on the type of piece?
I am not able to find such a case.
Edit :- I am adding the interface code that I am dealing with to make it more clear as asked by some people to give more context.
public class Chess {
ChessBoard chessBoard;
Player[] player;
Player currentPlayer;
List<Move> movesList;
GameStatus gameStatus;
public boolean playerMove(CellPosition fromPosition, CellPositionb toPosition, Piece piece);
public boolean endGame();
private void changeTurn();
}
public abstract class Piece {
Color color;
public boolean validate(CellPosition fromPosition, CellPositionb toPosition);
}
public class Knight extends Piece {
public boolean validate(CellPosition fromPosition, CellPositionb toPosition);
}
Similarly there will be classes for other pieces as Knight. Now if a player want to move in chess from some position X to another position Y, the validate() method of the Piece will be called by playerMove() of chess,validate() can only check whether the move is valid or not.Like for the given pieces,say knight, it will check that from given location,the destination is one of 8 valid moves.For Rook it can be any one of four directions and so on.
The playerMove() function makes a call the the Piece.validate() function and then it gets to know that it is a valid move.The problem that I am trying to address, now once playerMove function in chess, knows that it is valid move, it does not know that whether there is any piece in between from given location to destination?Because the piece dont have context of Board,it cannot detect it thing and it has to be done in playerMove() function of chess.So i will write a code here to generate the list of possible squares that are involved from source to destination. Will that list of squares will always be unique ?or can it be different for diffeent piece? Because apart from knight ,all moves in straight or diagonal so it should be unique ,so I want to clarify on this .If still question not clear, please let me know.but