Code:
$ ./a.out
0 1 2 3 4 5 6 7 8
+---+---+---+---+---+---+---+---+
| | | | | | | | | 0
+---+---+---+---+---+---+---+---+
|L12| |L11| |L10| |L9 | | 1
+---+---+---+---+---+---+---+---+
| |L8 | |L7 | |L6 | |L5 | 2
+---+---+---+---+---+---+---+---+
|L4 | |L3 | |L2 | |L1 | | 3
+---+---+---+---+---+---+---+---+
| | | | | | | | | 4
+---+---+---+---+---+---+---+---+
| | | | | | | | | 5
+---+---+---+---+---+---+---+---+
| |D1 | |D2 | |D3 | |D4 | 6
+---+---+---+---+---+---+---+---+
|D5 | |D6 | |D7 | |D8 | | 7
+---+---+---+---+---+---+---+---+
Why is there an 8 at the end of the top row?
Why are there 3 rows of L pieces?
Why don't the L pieces start in the first row?
/* If the value of board[i][j] is equal to 1, then that piece is Player 1's piece.
If the value of board[i][j] is equal to 2, then that piece is Player 2's piece.
board[i][j] is equal to 0 means that the location is not an outer bound area, (white squares)
board[i][j] is equal to 3 means that the location is a possible position but is empty */
Use an enum.
Code:
enum {
EMPTY = 0, // unused space
WHITE = 1, // white piece
BLACK = 2, // black piece
FREE = 3, // valid, but unused position
};
...
if(((i == 6)&&(j%2 == 1))||((i == 7)&&(j%2 == 0))||((i == 8)&&(j%2 == 1))) //Player 1 Pieces; valid square value is changed to 1
{
board[i][j] = WHITE;
}
else if(((i == 1)&&(j%2 == 0))||((i == 2)&&(j%2 == 1))||((i == 3)&&(j%2 == 0))) //Player 2 Pieces; valid square value is changed to 2
{
board[i][j] = BLACK;
}
else if((i + j)%2 == 1) //Checks all Valid Squares and value is set to 3
{
board[i][j] = FREE;
}
else
{
board[i][j] = EMPTY;
}