From 4e179b0677c5ee49aee3b76ffc62d613740f41b3 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sun, 5 May 2024 17:41:07 +0200 Subject: Reformatted possible_pawn_moves() --- FICS/movecheck.c | 81 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/FICS/movecheck.c b/FICS/movecheck.c index 5ffd3c4..ac20772 100644 --- a/FICS/movecheck.c +++ b/FICS/movecheck.c @@ -356,46 +356,49 @@ 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 -- cgit v1.2.3