how to check if a piece has an attack available (on your side )
Okay so i am kinda starting out C# and this whole thing is new to me so i am a little confused. Do i just loop through the entire board and checking every square or is there a craftier way to do this.
Help would be appreciated
By attack do you mean a capture move? If so, you can just loop through all the moves in board.getLegalMoves() and check if the start square of the move is the square of your piece and the captured piece of the move isn't PieceType.None
Use board.getLegalMoves(true)
Use board.getLegalMoves(true)
Specifically, the line:
Move[] allCaptureMoves = board.GetLegalMoves(true);
will give you all of your moves stored in an array variable named "allCaptureMoves". You can then iterate over these moves to check which pieces have captures available, or look to see if the piece you are interested in is in any of the moves in the array.