Skip to content

Instantly share code, notes, and snippets.

@pauldwhitman
Created March 10, 2013 11:00
Show Gist options
  • Save pauldwhitman/5128146 to your computer and use it in GitHub Desktop.
Save pauldwhitman/5128146 to your computer and use it in GitHub Desktop.
Part of the "Chess in C" blog post series. The first iteration of the board printing code.
/* Print the board */
/* For every row */
for (i = 0;i <= 7; i++) {
/* And every column */
for (j = 0;j <= 7; j++){
/* Get the board value */
boardValue = board[i][j];
/* And print the contents */
switch (boardValue) {
case EMPTY: printf(".");
break;
case KING: printf("K");
break;
case QUEEN: printf("Q");
break;
case ROOK: printf("R");
break;
case KNIGHT: printf("N");
break;
case BISHOP: printf("B");
break;
case PAWN: printf("P");
break;
case BREADCRUMB: printf("+");
break;
}
}
/* At the end of each row, make a new line */
printf("\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment