@@ -480,57 +480,64 @@ std::vector<piece_action> collect_all_pawn_en_passant_actions(
480
480
if (color == chess_color::black)
481
481
{
482
482
if (x != 3 ) return {};
483
+ if (y > 0 )
483
484
{
484
- if (y > 0 )
485
+ const square to_square{square (x - 1 , y - 1 )};
486
+ const square enemy_square{square (x, y - 1 )};
487
+ if (is_empty (g, to_square)
488
+ && is_piece_at (g, enemy_square)
489
+ && get_piece_at (g, enemy_square).get_color () == enemy_color
490
+ && has_just_double_moved (get_piece_at (g, enemy_square), g.get_time ())
491
+ )
485
492
{
486
- const square to_square{square (x - 1 , y - 1 )};
487
- const square enemy_square{square (x, y - 1 )};
488
- if (is_empty (g, to_square)
489
- && is_piece_at (g, enemy_square)
490
- && get_piece_at (g, enemy_square).get_color () == enemy_color
491
- && has_just_double_moved (get_piece_at (g, enemy_square), g.get_time ())
492
- )
493
- {
494
- actions.push_back (piece_action (color, type, piece_action_type::en_passant, from, to_square));
495
- }
493
+ actions.push_back (piece_action (color, type, piece_action_type::en_passant, from, to_square));
496
494
}
497
- if (y < 7 )
495
+ }
496
+ if (y < 7 )
497
+ {
498
+ const square to_square{square (x - 1 , y + 1 )};
499
+ const square enemy_square{square (x, y + 1 )};
500
+ if (is_empty (g, to_square)
501
+ && is_piece_at (g, enemy_square)
502
+ && get_piece_at (g, enemy_square).get_color () == enemy_color
503
+ && has_just_double_moved (get_piece_at (g, enemy_square), g.get_time ())
504
+ )
498
505
{
499
- const square to_square{square (x - 1 , y + 1 )};
500
- const square enemy_square{square (x, y + 1 )};
501
- if (is_empty (g, to_square)
502
- && is_piece_at (g, enemy_square)
503
- && get_piece_at (g, enemy_square).get_color () == enemy_color
504
- && has_just_double_moved (get_piece_at (g, enemy_square), g.get_time ())
505
- )
506
- {
507
- actions.push_back (piece_action (color, type, piece_action_type::en_passant, from, to_square));
508
- }
506
+ assert (!" YAY" );
507
+ actions.push_back (piece_action (color, type, piece_action_type::en_passant, from, to_square));
509
508
}
510
509
}
511
510
}
512
511
else
513
512
{
514
513
assert (color == chess_color::white);
515
- assert (get_rank (s) != 1 );
516
- // Attack
517
- if (x != 7 )
514
+ if (x != 4 ) return {};
515
+ if (y > 0 )
518
516
{
519
- if (y > 0 )
517
+ const square to_square{square (x + 1 , y - 1 )};
518
+ const square enemy_square{square (x, y - 1 )};
519
+ if (is_empty (g, to_square)
520
+ && is_piece_at (g, enemy_square)
521
+ && get_piece_at (g, enemy_square).get_color () == enemy_color
522
+ && has_just_double_moved (get_piece_at (g, enemy_square), g.get_time ())
523
+ )
520
524
{
521
- const square enemy_square{square (x + 1 , y - 1 )};
522
- if (is_piece_at (g, enemy_square) && get_piece_at (g, enemy_square).get_color () == enemy_color)
523
- {
524
- actions.push_back (piece_action (color, type, piece_action_type::attack, from, enemy_square));
525
- }
525
+ assert (!" YAY" );
526
+ actions.push_back (piece_action (color, type, piece_action_type::en_passant, from, to_square));
526
527
}
527
- if (y < 7 )
528
+ }
529
+ if (y < 7 )
530
+ {
531
+ const square to_square{square (x + 1 , y + 1 )};
532
+ const square enemy_square{square (x, y + 1 )};
533
+ if (is_empty (g, to_square)
534
+ && is_piece_at (g, enemy_square)
535
+ && get_piece_at (g, enemy_square).get_color () == enemy_color
536
+ && has_just_double_moved (get_piece_at (g, enemy_square), g.get_time ())
537
+ )
528
538
{
529
- const square enemy_square{square (x + 1 , y + 1 )};
530
- if (is_piece_at (g, enemy_square) && get_piece_at (g, enemy_square).get_color () == enemy_color)
531
- {
532
- actions.push_back (piece_action (color, type, piece_action_type::attack, from, enemy_square));
533
- }
539
+ assert (!" YAY" );
540
+ actions.push_back (piece_action (color, type, piece_action_type::en_passant, from, to_square));
534
541
}
535
542
}
536
543
}
0 commit comments