Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

http://www.gamesforthebrain.com/game/checkers/ Hi, I need to program a checkers

ID: 3688289 • Letter: H

Question

http://www.gamesforthebrain.com/game/checkers/

Hi,

I need to program a checkers game in C++ visual studio CLR console applicaiton. Most importantly the output visual should displace as above link., so two users should be able to make moves.

No computation in main function, No data collection in main function, no output command in main function, define all output messages beforehand (a library or messages) and use only a variable name in the output command, have a separate module for your standard greeting, allow flexibility to change number of resistors. No single (or two short) character identifiers (your identifiers should be meaningful). Comment your code heavily (i.e. identify each section and subsections

Explanation / Answer

#include<stdio.h>

#define ROWS 8
#define COLS 8

#define EMPTY 1
#define RED 2
#define BLACK 3
#define REDKING 4
#define BLAC
KKING 5


#define ISRED(c) (c == RED || c == REDKING)
#define ISBLACK(c) (c == BLACK || c == BLACKKING))
#define ISEMPTY(c) (c == 1)


void printDisplay(int d[][COLS]);
void swapIJKL(int d[ROWS][COLS], int i, int j, int k, int l);
char value2symbol(int i);
void printDisplayFancy(int d[][COLS]);
int Playersturn(int d[][COLS], int player,int i,int j,int k,int l);

void printDisplayFancy(int d[][COLS])
{
int rr, cc, pp;
  
printf(" +---+---+---+---+---+---+---+---+ ");
  
for (rr=0; rr<ROWS; ++rr)
{
printf("%d |", rr+1);
for (cc=0; cc<COLS; ++cc)
{

printf(" %c |", value2symbol(d[rr][cc]) );
}
printf(" ");
printf(" +---+---+---+---+---+---+---+---+ ");
}
  
printf(" a b c d e f g h ");
}

void swapIJKL(int d[ROWS][COLS], int i, int j, int k, int l)
{
int temp;
  
printf("SWAP: %d,%d to %d,%d ", i, j, k, l);
  
temp = d[i][j];
  
d[i][j] = d[k][l];
  
d[k][l] = temp;


}

char value2symbol(int i)
{

switch(i)
{
   case 0:
return ' ';
case 1:
return 'E';

case 2:
return '$';
case 3:
return '@';   
}
return ('?');
}

int Playersturn(int d[][COLS], int player,int i,int j,int k,int l)
{
int jmp_r;
int jmp_c;
  
if(player == RED){
printf("RED move from %d,%d to %d,%d ", i, j, k, l);
} else {
printf("BLACK move from %d,%d to %d,%d ", i, j, k, l);
}
  
if(i < 0 && ROWS <= i){ // keeping in bounds
printf("i is out of bounds ");
return -1;
}
if(j < 0 && COLS <= j){
printf("j is out of bound");
return -1;
}
  
if(k < 0 && ROWS <= k){
printf("k is out of bounds");
return -1;
  
}
if(l < 0 && COLS<= l){
printf("l is out of bounds ");

return -1;
}
  
// check player is moving his own piece.
if(player == RED){
if(d[i][j] != RED){
printf("move your own piece! ");
return -1;
}
} else { //BLACK
if(d[i][j] != BLACK){
printf("move your own piece! ");
return -1;
}
}
  
//make sure they are umping to a empty loacation
if(d[k][l] != EMPTY){
printf("You must move to a empty location");
return -1;
}
  
  
  
  
  
// make sure the vertical direction of the move is not illegal
if(player == RED){
//make sure he moves down
if(i >= k){
printf("RED player must move down ");