updated code, so to validate the pieces do i have to make a function that validates the pieces?
Code:
#include <stdio.h>
#include <Windows.h> //include the windows API to print unicode
//allows print unicode
//Sets-Up Checker Pieces by giving a value in a multidimensional array.
void initializeBoard(int board[8][8])
{
int i, j, k;
/* 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 */
//Player 1 Pieces
for(i = 0; i < 8; i++)
{
for(j = 0; j < 8; j++)
{
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] = 1;
}
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] = 2;
}
else if((i + j)%2 == 1) //Checks all Valid Squares and value is set to 3
{
board[i][j] = 3;
}
else
{
board[i][j] = 0;
}
}
}
}
void printBoard(int board[8][8])
{
int i, j, k;
int a = 0; //piece number for black
int b = 13; //piece number for white
//print column number
for(k = 0; k != 9; k++)
{
printf(" %d ",k);
}
//print board
printf("\n+---+---+---+---+---+---+---+---+\n"); //top row divider
for(i = 0; i <8; i++) //prints row with i being the number of rows
{
for(j = 0; j <8; j++)//prints column with j being the number of rows
{
if(board[i][j] == 1)
{
//spacing issues
a += 1;
if(a < 10) //if a single digit print piece with space
{
printf("|D%d ", a);
}
else //if not single digit print piece without space
{
printf("|D%d", a);
}
}
else if(board[i][j] == 2)
{
//spacing issues
b -= 1;
if(b < 10) //if a single digit print piece with space
{
printf("|L%d ", b);
}
else //if not single digit print piece without space
{
printf("|L%d", b);
}
}
else if(board[i][j] == 3)
{
printf("| â– ");
}
else
{
printf("| ");//print a column
}
}
printf("| %d", i); //outer right side border with row numbers
printf("\n"); //new line to signify new row
printf("+---+---+---+---+---+---+---+---+\n"); //row divider
}
}
int main()
{
SetConsoleOutputCP(CP_UTF8);
int board[8][8]; //board
initializeBoard(board);
printBoard(board);
return 0;
}