Skip to content

Commit

Permalink
the make unmake is not working. and pieces are attacking own pawns
Browse files Browse the repository at this point in the history
  • Loading branch information
TierynnB committed Aug 28, 2024
1 parent 103843a commit 527a492
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
18 changes: 16 additions & 2 deletions src/evaluate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn is_in_check(
let opponent_colour = if side_to_check == WHITE { BLACK } else { WHITE };

let king_location = board.get_king_location(side_to_check);

// println!("king location{:?}", king_location);
for (row_index, row) in board.colour_array.iter().enumerate() {
for (column_index, square_colour) in row.iter().enumerate() {
if square_colour != &opponent_colour {
Expand All @@ -60,16 +60,30 @@ pub fn is_in_check(
);

if outcome {
// println!(
// "king is attacked:{:?} from {}{}",
// king_location, row_index, column_index
// );

return outcome;
}
if aditional_square_to_check.is_some() {
return is_attacked_by_piece_from_square(
let outcome = is_attacked_by_piece_from_square(
board,
(row_index, column_index),
piece_type,
aditional_square_to_check.unwrap(),
opponent_colour,
);

if outcome {
// println!(
// "king is attacked:{:?} from {}{}",
// king_location, row_index, column_index
// );

return outcome;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/moveGen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ pub fn generate_pawn_moves(
let square_in_front = board.get_piece((index_of_square_in_front, column)); //board.board_array[index_of_square_in_front][column];

// if square not empty, return.
if square_in_front == 0 && blocked == false {
if square_in_front == 0 && !blocked {
moves.push(Move {
from: square,
from_piece: PAWN,
Expand Down
2 changes: 1 addition & 1 deletion src/moves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct Move {
impl Default for Move {
fn default() -> Self {
// return a default instance of Move
return Move {
return Move {
from: (0, 0),
from_piece: 0,
from_colour: 0,
Expand Down

0 comments on commit 527a492

Please sign in to comment.