| 626 } |
626 } |
| 627 } |
627 } |
| 628 } |
628 } |
| 629 |
629 |
| 630 for (uint8_t i = 0 ; i < candidatecount ; i++) { |
630 for (uint8_t i = 0 ; i < candidatecount ; i++) { |
| |
631 // TODO: check if we really need full-blown simulations here |
| 631 GameState simulation = gamestate_copy_sim(gamestate); |
632 GameState simulation = gamestate_copy_sim(gamestate); |
| 632 Move simmove = candidates[i]; |
633 Move simmove = candidates[i]; |
| 633 apply_move(&simulation, &simmove); |
634 apply_move(&simulation, &simmove); |
| 634 if (!is_covered(&simulation, kingrow, kingfile, |
635 if (!is_covered(&simulation, kingrow, kingfile, |
| 635 opponent_color(color))) { |
636 opponent_color(color))) { |
| 636 result = true; |
637 result = true; |
| 637 if (threats && threatcount) { |
638 if (threats && threatcount) { |
| 638 threats[(*threatcount)++] = candidates[i]; |
639 threats[(*threatcount)++] = candidates[i]; |
| 639 } |
640 } |
| 640 } |
641 } |
| |
642 gamestate_cleanup(&simulation); |
| 641 } |
643 } |
| 642 |
644 |
| 643 return result; |
645 return result; |
| 644 } else { |
646 } else { |
| 645 return false; |
647 return false; |