Skip to content

Instantly share code, notes, and snippets.

@pauldwhitman
Last active December 14, 2015 18:48
Show Gist options
  • Save pauldwhitman/5131580 to your computer and use it in GitHub Desktop.
Save pauldwhitman/5131580 to your computer and use it in GitHub Desktop.
Part of the "Chess in C" blog post series. Calculates the square used by the pawn if it moves by one square. Intentionally contains an array out of bounds bug.
/* Calculate a pawn move */
/* For every row */
for (i = 0;i <= 7; i++) {
/* And every column */
for (j = 0;j <= 7; j++){
/* If this square contains a pawn.. */
if (board[i][j] == PAWN) {
/* ..mark the square below as being a potential move */
board[i+1][j] = POTENTIAL_MOVE_PAWN;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment