diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-03-17 19:06:52 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-03-17 19:06:52 +0100 |
commit | 29355ca6f150e55b25dba3fda7f5ce146798408a (patch) | |
tree | 64f4e00cc6bbf69398a886a6f84ebf7abd1b0f2c /FICS/movecheck.c | |
parent | 3b12135bc38e40dc9814726b861bf2b4ac7c512d (diff) |
Reformatted possible_pawn_moves()
Diffstat (limited to 'FICS/movecheck.c')
-rw-r--r-- | FICS/movecheck.c | 85 |
1 files changed, 46 insertions, 39 deletions
diff --git a/FICS/movecheck.c b/FICS/movecheck.c index a4fa18f..cab73ac 100644 --- a/FICS/movecheck.c +++ b/FICS/movecheck.c @@ -340,46 +340,53 @@ PRIVATE void add_pos(int tof, int tor, int *posf, int *posr, int *numpos) (*numpos)++; } -PRIVATE void possible_pawn_moves(game_state_t * gs, - int onf, int onr, - int *posf, int *posr, int *numpos) +PRIVATE void +possible_pawn_moves(game_state_t *gs, int onf, int onr, int *posf, int *posr, + int *numpos) { - if (gs->onMove == WHITE) { - if (gs->board[onf][onr + 1] == NOPIECE) { - add_pos(onf, onr + 1, posf, posr, numpos); - if ((onr == 1) && (gs->board[onf][onr + 2] == NOPIECE)) - add_pos(onf, onr + 2, posf, posr, numpos); - } - if ((onf > 0) && (gs->board[onf - 1][onr + 1] != NOPIECE) && - (iscolor(gs->board[onf - 1][onr + 1], BLACK))) - add_pos(onf - 1, onr + 1, posf, posr, numpos); - if ((onf < 7) && (gs->board[onf + 1][onr + 1] != NOPIECE) && - (iscolor(gs->board[onf + 1][onr + 1], BLACK))) - add_pos(onf + 1, onr + 1, posf, posr, numpos); - if (gs->ep_possible[0][onf] == -1) - add_pos(onf - 1, onr + 1, posf, posr, numpos); - if (gs->ep_possible[0][onf] == 1) - add_pos(onf + 1, onr + 1, posf, posr, numpos); - } else { - if (gs->board[onf][onr - 1] == NOPIECE) { - add_pos(onf, onr - 1, posf, posr, numpos); - if ((onr == 6) && (gs->board[onf][onr - 2] == NOPIECE)) - add_pos(onf, onr - 2, posf, posr, numpos); - } - if ((onf > 0) && (gs->board[onf - 1][onr - 1] != NOPIECE) && - (iscolor(gs->board[onf - 1][onr - 1], WHITE))) - add_pos(onf - 1, onr - 1, posf, posr, numpos); -/* loon: changed what looks like a typo, here's the original line: - add_pos(onf - 1, onr + 1, posf, posr, numpos); -*/ - if ((onf < 7) && (gs->board[onf + 1][onr - 1] != NOPIECE) && - (iscolor(gs->board[onf + 1][onr - 1], WHITE))) - add_pos(onf + 1, onr - 1, posf, posr, numpos); - if (gs->ep_possible[1][onf] == -1) - add_pos(onf - 1, onr - 1, posf, posr, numpos); - if (gs->ep_possible[1][onf] == 1) - add_pos(onf + 1, onr - 1, posf, posr, numpos); - } + if (gs->onMove == WHITE) { + if (gs->board[onf][onr + 1] == NOPIECE) { + add_pos(onf, onr + 1, posf, posr, numpos); + + if (onr == 1 && gs->board[onf][onr + 2] == NOPIECE) + add_pos(onf, onr + 2, posf, posr, numpos); + } + + if (onf > 0 && + gs->board[onf - 1][onr + 1] != NOPIECE && + iscolor(gs->board[onf - 1][onr + 1], BLACK)) + add_pos(onf - 1, onr + 1, posf, posr, numpos); + if (onf < 7 && + gs->board[onf + 1][onr + 1] != NOPIECE && + iscolor(gs->board[onf + 1][onr + 1], BLACK)) + add_pos(onf + 1, onr + 1, posf, posr, numpos); + + if (gs->ep_possible[0][onf] == -1) + add_pos(onf - 1, onr + 1, posf, posr, numpos); + if (gs->ep_possible[0][onf] == 1) + add_pos(onf + 1, onr + 1, posf, posr, numpos); + } else { + if (gs->board[onf][onr - 1] == NOPIECE) { + add_pos(onf, onr - 1, posf, posr, numpos); + + if (onr == 6 && gs->board[onf][onr - 2] == NOPIECE) + add_pos(onf, onr - 2, posf, posr, numpos); + } + + if (onf > 0 && + gs->board[onf - 1][onr - 1] != NOPIECE && + iscolor(gs->board[onf - 1][onr - 1], WHITE)) + add_pos(onf - 1, onr - 1, posf, posr, numpos); + if (onf < 7 && + gs->board[onf + 1][onr - 1] != NOPIECE && + iscolor(gs->board[onf + 1][onr - 1], WHITE)) + add_pos(onf + 1, onr - 1, posf, posr, numpos); + + if (gs->ep_possible[1][onf] == -1) + add_pos(onf - 1, onr - 1, posf, posr, numpos); + if (gs->ep_possible[1][onf] == 1) + add_pos(onf + 1, onr - 1, posf, posr, numpos); + } } PRIVATE void |