This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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("."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (i=0; i<=7; i++) { | |
/* And every column */ | |
for (j=0; j<=7; j++) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Zero out the board */ | |
for (i = 0; i <= 7; i++) { | |
for (j = 0; j <= 7; j++) { | |
/* Zero out the square */ | |
board[i][j] = 0; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
board[4][4] = BISHOP; | |
board[4][5] = BISHOP; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Iterate backward through board */ | |
for (i = 7; i >= 0; i--) { | |
for (j = 7; j >= 0; j--) { | |
/* Zero out the square */ | |
board[i][j] = 0; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Calculate possible up-left diagonal destinations | |
* This requires the loop to iterate backwards as we are | |
* checking cells BEFORE the bishop */ | |
for (i=7; i>=0; i--) { | |
for (j=7; j>=0; j--){ | |
/* If 1) the cell to right is inbounds of the array and | |
* 2) the cell isn't not on the final row */ | |
if ((j+1 != 8) && (i != 7)) { | |
/* ...AND the above-right cell has a bishop OR a breadcrumb ... */ | |
if (board[i+1][j+1] == BISHOP || board[i+1][j+1] == POTENTIAL_MOVE_BISHOP) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define EMPTY 0 | |
#define KING 1 | |
#define QUEEN 2 | |
#define ROOK 3 | |
#define KNIGHT 4 | |
#define BISHOP 5 | |
#define PAWN 6 | |
#define BREADCRUMB 9 | |
#define POTENTIAL_MOVE_KING 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#define EMPTY 0 | |
#define KING 1 | |
#define QUEEN 2 | |
#define ROOK 3 | |
#define KNIGHT 4 | |
#define BISHOP 5 | |
#define PAWN 6 | |
#define BREADCRUMB 9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define POTENTIAL_MOVE_KING 10 | |
#define POTENTIAL_MOVE_QUEEN 20 | |
#define POTENTIAL_MOVE_ROOK 30 | |
#define POTENTIAL_MOVE_KNIGHT 40 | |
#define POTENTIAL_MOVE_BISHOP 50 | |
#define POTENTIAL_MOVE_PAWN 60 |