What is a good algorithim to pass through the void playGame() function

#include <iostream>
#include <cmath>

using namespace std;

// check if a certain position on the board is occupied by a red or black piece
string checkPos(int x, int y, int red[][6], int black[][6])
{
string str = "";
if(red[x][y] != 0)
if(red[x][y] == 1)
str = "r1";
else
str = "r2";
else if(black[x][y] != 0)
if(black[x][y] == 1)
str = "b1";
else
str = "b2";
else
str = " ";

return str;
}

//print board according to red and black arrays indicating positions on the board
void printBoard(int red[][6], int black[][6])
{
cout << "\n";
cout << " ____ ____ ____ ____ ____ ____ " << endl;
cout << " | | | | | | |" << endl;
cout << "5 | " << checkPos(0, 5, red, black) << " | | " << checkPos(2, 5, red, black) << " | | " << checkPos(4, 5, red, black) << " | |" << endl;
cout << " |____|____|____|____|____|____|" << endl;
cout << " | | | | | | |" << endl;
cout << "4 | | " << checkPos(1, 4, red, black) << " | | " << checkPos(3, 4, red, black) << " | | " << checkPos(5, 4, red, black) << " |" << endl;
cout << " |____|____|____|____|____|____|" << endl;
cout << " | | | | | | |" << endl;
cout << "3 | " << checkPos(0, 3, red, black) << " | | " << checkPos(2, 3, red, black) << " | | " << checkPos(4, 3, red, black) << " | |" << endl;
cout << " |____|____|____|____|____|____|" << endl;
cout << " | | | | | | |" << endl;
cout << "2 | | " << checkPos(1, 2, red, black) << " | | " << checkPos(3, 2, red, black) << " | | " << checkPos(5, 2, red, black) << " |" << endl;
cout << " |____|____|____|____|____|____|" << endl;
cout << " | | | | | | |" << endl;
cout << "1 | " << checkPos(0, 1, red, black) << " | | " << checkPos(2, 1, red, black) << " | | " << checkPos(4, 1, red, black) << " | |" << endl;
cout << " |____|____|____|____|____|____|" << endl;
cout << " | | | | | | |" << endl;
cout << "0 | | " << checkPos(1, 0, red, black) << " | | " << checkPos(3, 0, red, black) << " | | " << checkPos(5, 0, red, black) << " |" << endl;
cout << " |____|____|____|____|____|____|" << endl;
cout << " 0 1 2 3 4 5 \n" << endl;
}

void initializePieces(int red[][6], int black[][6])
{
for(int i = 0; i < 6; i++)
for(int j = 0; j < 6; j++)
{
red[i][j] = 0;
black[i][j] = 0;
}
red[0][1] = 1;
red[1][0] = 2;
red[2][1] = 1;
red[3][0] = 2;
red[4][1] = 1;
red[5][0] = 2;

black[0][5] = 2;
black[1][4] = 1;
black[2][5] = 2;
black[3][4] = 1;
black[4][5] = 2;
black[5][4] = 1;

}

void playGame(int red[][6], int black[][6], int &redPoints, int &blackPoints)
{

}

int main()
{
int red[6][6];
int black[6][6];
int redPoints = 0;
int blackPoints = 0;
initializePieces(red, black);
printBoard(red, black);
playGame(red, black, redPoints, blackPoints);
return 0;
}
I suggest a neuro fuzzy approach that learns as it goes. That way, it will become stronger every game it plays.


Of course, we have no idea what game this is, what the rules are, or anything else (I was able to deduce 2 player game, but not much more -- I suspected checkers for a bit but it has a score, so that is out).

Topic archived. No new replies allowed.