```
#include "Header1.h"
#include <stdio.h>
#include <stdlib.h>
int main()
{
Board::Boardstate();
Board::GenerateMoves();
}
void Board::Boardstate()
{
int Board[28];
int dice[2];
Board[6] = 5;
Board[8] = 3;
Board[13] = 5;
Board[24] = 2;
Board[1] = -2;
Board[12] = -5;
Board[17] = -3;
Board[19] = -5;
}
void Board::GenerateMoves(int *dice, int *point, int player)
{
int checker1;
int checker2;
int dice1 = dice[0];
int dice2 = dice[1];
int destination1;
int destination2;
bool checkeronbar = false;
int NumberofCheckers;
int i;
int a;
int f;
if (player ==1)
{
for(i=24; i>0; i--)
if(point[i] > 0)
{
checker1 = i; //find 1st checker that can be moved
if(checkeronbar = true) //for checking if a checker is on the bar
{
// checker on the bar has to be moved first so there is no method
}
else
{
destination1 = checker1 - dice1;
int nextdestination = destination1; //to be able to move the same checker twice in one move
destination2 = nextdestination - dice2;
}
}
for(a = checker1; a>0; a--)
if(point[a] > 1) //checks to see if there is more than 1 checker on the point
{
if(a == i) //checking if this is at the posiiton of checker1
{
NumberofCheckers = point[a]-1; //remove the checker from the count of checkers at that point
}
else
{
NumberofCheckers = point[a];
}
for (f = 0; f<NumberofCheckers; f++)
{
checker2 = a;
if(checkeronbar == true) //for checking if a checker is on the bar
{
checker1 = 26;
destination1 = 25 - dice1;
}
else
{
destination1 = checker1 - dice1;
}
destination2 = checker2 - dice2;
if(checkeronbar == true) //for checking if a checker is on the bar
{
checker1 = 26;
destination1 = 25 - dice2;
}
else
{
destination1 = checker1 - dice2;
}
destination2 = checker2 - dice1;
}
}
else if(point[a] == 1)
{
if((a!=i) || (checkeronbar == true))
{
checker2 = a;
if (checkeronbar == true)
{
checker1 = 26;
destination1 = 25 - dice1;
}
else
{
destination1 = checker1 - dice1;
}
destination2 = checker2 - dice2;
if (checkeronbar == true)
{
checker1 = 26;
destination1 = 25-dice2;
}
else
{
destination1 = checker1 - dice2;
}
destination2 = checker2 - dice1;
}
}
}
else if (player ==2)
{
for(i=24; i>0; i--)
if(point[i] > 0)
{
checker1 = i; //find 1st checker that can be moved
if(checkeronbar = true) //for checking if a checker is on the bar
{
// checker on the bar has to be moved first so there is no method
}
else
{
destination1 = checker1 + dice1;
int nextdestination = destination1; //to be able to move the same checker twice in one move
destination2 = nextdestination - dice2;
}
}
for(a=checker1; a>0; a--)
if(point[a] > 1) //checks to see if there is more than 1 checker on the point
{
if(a == i) //checking if this is at the posiiton of checker1
{
NumberofCheckers = point[a]+1; //remove the checker from the count of checkers at that point
}
else
{
NumberofCheckers = point[a];
}
for (f = 0; f<NumberofCheckers; f++)
{
checker2 = a;
if(checkeronbar == true) //for checking if a checker is on the bar
{
checker1 = 26;
destination1 = 25 + dice1;
}
else
{
destination1 = checker1 + dice1;
}
destination2 = checker2 + dice2;
if(checkeronbar == true) //for checking if a checker is on the bar
{
checker1 = 26;
destination1 = 25 + dice2;
}
else
{
destination1 = checker1 + dice2;
}
destination2 = checker2 + dice1;
}
}
else if(point[a] == 1)
{
if((a!=i) || (checkeronbar == true))
{
checker2 = a;
if (checkeronbar == true)
{
checker1 = 26;
destination1 = 25 + dice1;
}
else
{
destination1 = checker1 + dice1;
}
destination2 = checker2 + dice2;
if (checkeronbar == true)
{
checker1 = 26;
destination1 = 25 + dice2;
}
else
{
destination1 = checker1 + dice2;
}
destination2 = checker2 + dice1;
}
}
}
}
```