Unverified Commit 86899472 authored by Thomas R. Koll's avatar Thomas R. Koll
Browse files

Add Game struct and start with turn()

parent 8fe9feb8
......@@ -37,6 +37,12 @@ struct Stone {
int position; // where a stone is at right now
};
struct Game {
int numberOfTurns;
int playingField;
Game() : numberOfTurns(0), playingField(0) {};
};
// two bit masks to with the board layout for each player
// starts with the each player's four outer fields, followed
// by the eight shared field and again each player's two outer finish fields
......@@ -49,9 +55,11 @@ const unsigned int playerOneField = 0b11110000111111111100;
const unsigned int playerTwoField = 0b00001111111111110011;
const unsigned int protectedFields = 0b1111111110001; // it's just one field in the middle
Game game;
void throwDice( int dice) {
dice = 0;
for (int i = 0; i < 3; i++ ) {
for (int i = 0; i < 4; i++ ) {
dice = (dice << 1) | (rand() % 2);
}
#ifdef DEBUG
......@@ -59,13 +67,28 @@ void throwDice( int dice) {
#endif
}
int turn(Player player) {
#ifdef DEBUG
printf("New turn #%i\n", game.numberOfTurns);
#endif
static int dice;
throwDice(dice);
// wait for user input
}
int moveStone(Player player, Stone stone, int value) {
}
int main() {
game = Game();
srand (time(NULL));
Player playerOne(playerOneField);
Player playerTwo(playerTwoField);
static int dice;
throwDice(dice);
#ifdef DEBUG
printf("Starting game...\n");
#endif
while(playerOne.score < 6 && playerTwo.score < 6 && game.numberOfTurns < 100) {
game.numberOfTurns++;
turn(game.numberOfTurns % 2 ? playerOne : playerTwo);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment