|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T p
Length: 1505 (0x5e1) Types: TextFile Names: »piecemoves.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Kriegspiel/piecemoves.c«
/* piecemoves.c */ #include "externs.h" LIST piecemoves (from, ignoreenemy) /* doesn't include castling */ int from, ignoreenemy; { int piece, color, front, spot, side, addend, to; LIST dirs, moves, linsert (); piece = occupant [from]; color = whose [from]; moves = NIL; if (piece == PAWN) { front = from + pawndir [color]; if (whose [front] != color && (ignoreenemy || whose [front] == EMPTY)) { moves = linsert (moves, front); if (from / 10 == 7 - 5 * color) { /* pawn can move 2 */ spot = front + pawndir [color]; if (whose [spot] != color && (ignoreenemy || whose [spot] == EMPTY)) moves = linsert (moves, spot); } } for (side = -1; side <= 1; side += 2) { spot = front + side; if (whose [spot] != color && whose [spot] != OFFBOARD && (ignoreenemy || whose [spot] == 1 - color || (from / 10 == 4 + color /* en passent */ && occupant [from + side] == PAWN && lastmovefrom == spot + pawndir [color] && lastmoveto == from + side))) moves = linsert (moves, spot); } } else { dirs = dirlist [piece]; while (dirs != NIL) { addend = dirs->i; dirs = dirs->n; to = from; while (TRUE) { to += addend; if (to < 0 || to > 99) break; if (whose [to] == OFFBOARD || whose [to] == color) break; moves = linsert (moves, to); if (ignoreenemy == FALSE && whose [to] == 1 - color) break; if (piece == KING || piece == KNIGHT) break; } } } return moves; }