You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Perhaps there's a different endpoint I should be using to determine whether a move is legal. But when developing a UI with this library, I need a way to determine whether a player-input move is legal. This function sounds like the right one, however it only checks for specific illegal moves- it doesn't check for instance whether the position the piece is moving to is within its capabilities. For instance, I can move a pawn sideways.
I would expect the following test to pass:
public void MoveIsLegal()
{
var illegalMove = Move.Create(Square.F2, Square.F6);
// construct game and start a new game
var game = GameFactory.Create(Fen.Fen.StartPositionFen);
var position = game.Pos;
var state = new State();
// verify in check is actually true
Assert.False(position.IsLegal(illegalMove));
}
The text was updated successfully, but these errors were encountered:
You wish to determine whether or not a move can be performed, based on the source piece being attempted to move to somewhere else on the board.
The Position.IsLegal(Move) method actually expects the move you pass in the be a legal move, in fact the move generator use this method to assist with legal state detection. This is possible because the moves being checked are always "actual" moves based on the rules of chess for the various pieces.
You would have to check that based on the legal moves from the current position.
You would need to convert the move into something more accurate that the library can understand.
Then iterate through the legal moves and check if that move is one of the legal moves.
This sounds like the same kind of solution when parsing in a position and a chain of moves from let's say the UCI protocol. There you typically have the startposition followed by all the moves performed so far. These moves would need to be converted into something move useful that just a source and a destination move.
Something along the lines of (and you can use the move list pool here as well):
This will accept the position and the uci move fx. "a2a3" and then return the actual Move that matches of Move.EmptyMove if no move exists that matches.
Perhaps there's a different endpoint I should be using to determine whether a move is legal. But when developing a UI with this library, I need a way to determine whether a player-input move is legal. This function sounds like the right one, however it only checks for specific illegal moves- it doesn't check for instance whether the position the piece is moving to is within its capabilities. For instance, I can move a pawn sideways.
I would expect the following test to pass:
The text was updated successfully, but these errors were encountered: