I'm trying to implement a simple version of Wari logical board game. My implementation supposes to allow two humans to play the game. I have created array of 12 elements, each element represent the square. Every square has a number of stones. My problem is that I don’t know how to manipulate, get access, and change the "square", "numStones" variables.
The program is so far:
// Wari
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
using namespace std;
int i;
int m = 0;
bool exitGame = false;
int numStones = 4;
int score1 = 0;
int score2 = 0;
const int arraySize =12;
char side1[] = {'f','e','d','c','b','a'};
char side2[] = {'A','B','C','D','E','F'};
int board[12];
void printSide1(char side1[6])
{
for ( int n = 0; n < 6 ; n++)
{
cout <<" " << side1[n] <<" ";
}
cout<<endl;
}
void printSide2(char side2[6])
{
for ( int m = 0; m < 6 ; m++)
{
cout <<" " << side2[m] <<" ";
}
cout<<endl;
}
bool emptySquare(){
if(square == 0) return true;
return false;}
void printBoard(int board[12] )
{
for (int i=0; i<13; i++)
{
if(i==6) cout << endl;
else cout << " " << numStones << " ";
}
cout<< endl;
}
void Update(int board[], int square, int numStones)
{
//content
}
void gameDisplay()
{
printSide1(side1);
printBoard(board);
Update( board, square, numStones);
printSide2(side2);
}
bool illegalMove1()
{
bool legal = (square >= 0 && square <= 5);
return !legal;
}
bool illegalMove2()
{
bool legal = (square >= 6 && square <= 11);
return !legal;
}
void Move_Player1()
{
do
{
cout << "Player1, please make your move: f, e, d, c, b , a..." <<endl;
cin >> square;
switch(square)
{
case 'f':
square = 0;
break;
case 'e':
square = 1;
break;
case 'd':
square = 2;
break;
case 'c':
square = 2;
break;
case 'b':
square = 3;
break;
case 'a':
square = 4;
break;
}
cout << "square index:" << (int)square << endl;
}while ( illegalMove1() );
}
void Move_Player2()
{
do
{
cout << "Player2, please make your move: A, B, C, D, E, F..." <<endl;
cin >> square;
switch(square)
{
case 'A':
square = 6;
break;
case 'B':
square = 7;
break;
case 'C':
square = 8;
break;
case 'D':
square = 9;
break;
case 'E':
square = 10;
break;
case 'F':
square = 11;
break;
}
cout << "square index:" << (int)square << endl;
}
while (illegalMove2());
}
int main()
{
int score1 = 0;
int score2 = 0;
cout<< endl;
cout<<" WELCOME TO THE GAME OF WARI" <<endl;
cout<< endl;
cout<<"Player1 score: "<< score1 <<endl;
cout<<"Player2 score: "<< score2 <<endl;
cout << endl;
while( !exitGame)
{
if (m % 2 == 0)
{
Move_Player1();
}
else
{
Move_Player2();
}
m++;
gameDisplay();
if( score1 == 25 || score2 == 25)
{
exitGame = true;
}
if(exitGame == true)
{
cout << "Winner is :" <<endl;
}
}
}
Thank you.
Below you can see the actual output after compiling the code.