Esempio n. 1
0
//Tests conditions for path, which needs 1 BPS and 1 BQN
//Ensure paths are connected to other paths & are legal paths
//Does not leave into the sea, and path is vacant
int arcConditions (Game g, action a, int player) {

	int answer = TRUE;
	char *path = a.destination;
	edge arc;
	arc.pointA = pathMovement (path);
	arc.pointB = movement (arc.pointA, BACK);

	if ((getStudents (g, player, STUDENT_BPS) >= 1) 
		&& (getStudents (g, player, STUDENT_BQN) >= 1)
		&& (a.destination[0] != BACK)) { //doesn't move back into the sea
		answer = TRUE;
	} else {
		answer = FALSE;
	}

	//check if they're inside the boundaries
	if (answer == TRUE
		&& abs (arc.pointA.x) >= 3
		&& abs (arc.pointA.y) >= 3
		&& abs (arc.pointA.z) >= 3) {
		answer = FALSE;
	}

	//Checks to see that they are actual adjacent vertexes
	if (answer == TRUE 
		&& abs(arc.pointA.x+arc.pointA.y+arc.pointA.z) != 2 
		&& (arc.pointA.x+arc.pointA.y+arc.pointA.z+arc.pointB.x+arc.pointB.y+arc.pointB.z != 0)
		&& (getARC (g, a.destination) != VACANT_ARC)) {
		answer = FALSE;
	} 

	return answer;
}
Esempio n. 2
0
//returns 1 if player can afford a campus
static int canAffordCampus(Game g, int player) {
    int valid = 1;
    valid = canAffordARC(g, player);
    if (getStudents(g, player, STUDENT_MJ) == 0) {
        valid = 0;
    } else if (getStudents(g, player, STUDENT_MTV) == 0) {
        valid = 0;
    }
    return valid;
}
Esempio n. 3
0
int enoughToBuildPath(Game g, int playerId) {
	int result = FALSE;

	if (getStudents(g, playerId, STUDENT_BPS) >= 1 &&
		getStudents(g, playerId, STUDENT_BQN) >= 1) {
		result = TRUE;
	}

	return result;
}
Esempio n. 4
0
//If the player has more than 3 or the non-core students
static int canTradeJunkResources(Game g, int player) {
    int resourceFrom = 0;
    if (getStudents(g, player, STUDENT_MTV) >=
        getExchangeRate(g, player, STUDENT_MTV, 1)) {
        resourceFrom = STUDENT_MTV;
    } else if (getStudents(g, player, STUDENT_MMONEY) >=
        getExchangeRate(g, player, STUDENT_MMONEY, 1)) {
        resourceFrom = STUDENT_MMONEY;
    }
    return resourceFrom;
}
Esempio n. 5
0
//returns 1 if the player can afford to build an arc
static int canAffordARC(Game g, int player) {
    
    int valid = 1;
    
    if (getStudents(g, player, STUDENT_BPS) < 1) {
        valid = 0;
    } else if (getStudents(g, player, STUDENT_BQN) < 1) {
        valid = 0;
    }
    return valid;
}
Esempio n. 6
0
//returns 1 if the player can afford to build a spinoff
static int canAffordSpinOff(Game g, int player) {
    
    int valid = 1;
    
    if (getStudents(g, player, STUDENT_MJ) < 1) {
        valid = 0;
    } else if (getStudents(g, player, STUDENT_MTV) < 1) {
        valid = 0;
    } else if (getStudents(g, player, STUDENT_MMONEY) < 1) {
        valid = 0;
    }
    return valid;
}
Esempio n. 7
0
static int resourcesWeNeed (Game g, int player, int resourceFrom) {
    int resourceTo = STUDENT_BPS;

    int bqn = getStudents(g, player, STUDENT_BQN);
    int bps = getStudents(g, player, STUDENT_BPS);
    int mj  = getStudents(g, player, STUDENT_MJ);

    if (bqn < bps && bqn < mj) {
        resourceTo = STUDENT_BQN;
    } else if (mj < bps && mj < bqn && resourceFrom != STUDENT_MJ) {
        resourceTo = STUDENT_MJ;
    }
    return resourceTo;
}
Esempio n. 8
0
//Returns true/false based on whether it suits retraining conditions
//Ensures valid discipline numbers used
//Ensures enough students for retraining
//THDs cannot be retrained, (code 0)
int retrainConditions (Game g, action a, int player) {
	
	int answer = FALSE;
	int rate = 0;
	int numStudents = 0;

	rate = getExchangeRate (g, player, a.disciplineFrom, a.disciplineTo);
	numStudents = getStudents (g, player, a.disciplineFrom);

	if (numStudents < rate) {
		return FALSE;
	}

	if ((answer == TRUE) && (a.disciplineTo >= 0) 
		&& (a.disciplineFrom > 0)
		&& (a.disciplineTo < MAX_STU_TYPES)
		&& (a.disciplineFrom < MAX_STU_TYPES)
		&& (numStudents >= rate)) {

		answer = TRUE;
	} else {
		answer = FALSE;
	}
	
	return answer;
	printf ("answer is %d\n", answer);
}
Esempio n. 9
0
//Tests conditions for G08, which needs a campus + 2MJs + 3M$ 
int G08Conditions (Game g, action a, int player) {

	int answer = FALSE;
	char *path = a.destination;
	coord vertex = pathMovement (path);
	coord adj = movement (vertex, BACK);


	if ((getStudents (g, player, STUDENT_MJ) >= 2) 
		&& (getStudents (g, player, STUDENT_MMONEY) >= 3)
		&& (getCampuses (g, player) > 0)
		&& (getGO8s (g, player) < MAX_G08S)
		&& (getCampus (g, a.destination) > 3)) {

		answer = TRUE;
	} else {
		answer = FALSE;
	}

	//check if they're inside the boundaries
	if (answer == TRUE
		&& abs (vertex.x) >= 3
		&& abs (vertex.y) >= 3
		&& abs (vertex.z) >= 3) {
		answer = FALSE;
	}

	//Checks for adjacent campuses which would be illegal
	if (answer == TRUE
		&& g->gameBoard.campus[adj.x][adj.y][adj.z] != NO_ONE) {
		answer = FALSE;
	}


	//Checks that it's a vertex
	if (answer == TRUE
		&& abs (vertex.x+vertex.y+vertex.z) != 2) {
		answer = FALSE;
	}

	return answer;
}
Esempio n. 10
0
// test starting spinoffs
void test9 (void) {
    action a;
    int disciplines[] = {2,5,3,5,3,1,4,4,1,4,2,3,2,0,3,5,4,2,1};
    int dice[] = {9,10,8,12,6,5,3,11,3,11,4,6,4,7,9,2,8,10,5};
    Game g = newGame(disciplines, dice);
    throwDice(g, 8);
    a.actionCode = OBTAIN_ARC;
    strncpy(a.destination, "R", PATH_LIMIT - 1);
    a.destination[PATH_LIMIT - 1] = 0;
    a.disciplineFrom = -1217350860, a.disciplineTo = 7;
    makeAction(g, a);
    a.actionCode = OBTAIN_ARC;
    strncpy(a.destination, "RR", PATH_LIMIT - 1);
    a.destination[PATH_LIMIT - 1] = 0;
    a.disciplineFrom = -1217350860, a.disciplineTo = 7;
    makeAction(g, a);
    a.actionCode = PASS;
    strncpy(a.destination, "", PATH_LIMIT - 1);
    a.destination[PATH_LIMIT - 1] = 0;
    a.disciplineFrom = -1078711464, a.disciplineTo = 134586891;
    makeAction(g, a);
    throwDice(g, 5);
    a.actionCode = OBTAIN_ARC;
    strncpy(a.destination, "RRLRLL", PATH_LIMIT - 1);
    a.destination[PATH_LIMIT - 1] = 0;
    a.disciplineFrom = -1217350860, a.disciplineTo = 7;
    makeAction(g, a);
    a.actionCode = PASS;
    strncpy(a.destination, "", PATH_LIMIT - 1);
    a.destination[PATH_LIMIT - 1] = 0;
    a.disciplineFrom = -1078711464, a.disciplineTo = 134586891;
    makeAction(g, a);
    throwDice(g, 6);
    a.actionCode = OBTAIN_PUBLICATION;
    strncpy(a.destination, "", PATH_LIMIT - 1);
    a.destination[PATH_LIMIT - 1] = 0;
    a.disciplineFrom = 1, a.disciplineTo = 2329;
    printf("%d\n", getStudents(g, 3, 3));
    makeAction(g, a);
    assert(getStudents(g, 3, 3) == 1);
}
Esempio n. 11
0
//Returns true/false, tests conditions for campus,
// which needs 1 of each but THD or M$,
// and no two campuses can be on adjacent vertexes
int cmpsConditions (Game g, action a, int player) {

	int answer = TRUE;
	char *path = a.destination;
	coord vertex = pathMovement (path);
	coord adj = movement (vertex, BACK);

	if ((getStudents (g, player, STUDENT_BPS) >= 1) 
		&& (getStudents (g, player, STUDENT_BQN) >= 1)
		&& (getStudents (g, player, STUDENT_MJ) >= 1)
		&& (getStudents (g, player, STUDENT_MTV) >= 1)
		&& (getCampus (g, a.destination) == VACANT_VERTEX)
		&& (getARC (g, a.destination) != VACANT_ARC)) {
		answer = TRUE;
	} else {
		answer = FALSE;
	}
	
	//check if they're inside the boundaries
	if (answer == TRUE
		&& abs (vertex.x) >= 3
		&& abs (vertex.y) >= 3
		&& abs (vertex.z) >= 3) {
		answer = FALSE;
	}


	//Checks for adjacent campuses which would be illegal
	if (answer == TRUE
		&& g->gameBoard.campus[adj.x][adj.y][adj.z] != NO_ONE) {
		answer = FALSE;
	}

	//Check that it's an actual vertex
	if (answer == TRUE
		&& abs (vertex.x+vertex.y+vertex.z) != 2) {
		answer = FALSE;
	}

	return answer;
}
Esempio n. 12
0
void throwDice(Game g, int diceScore) {
  g->currentTurn++;

  assert((diceScore >= DICE_MINIMUM) && (diceScore <= DICE_MAXIMUM));
  if(diceScore == AUTO_RETRAIN) {
    int player = 0;
    int numberOfMTV = getStudents(g, player, STUDENT_MTV);
    int numberOfMMONEY = getStudents(g, player, STUDENT_MMONEY);
    // basically looks at index of students array within each respective index
    // in the players array. each player has a students array!
    // when a 7 is rolled, follow instructions
    while(player < NUM_UNIS) {
      g->players[player].students[STUDENT_MTV] -= numberOfMTV;
      g->players[player].students[STUDENT_THD] += numberOfMTV;
      g->players[player].students[STUDENT_MMONEY] -= numberOfMMONEY;
      g->players[player].students[STUDENT_THD] += numberOfMMONEY;

      player++;
    }
  }
}
Esempio n. 13
0
void printScore (Game g) {
    int player = getWhoseTurn (g);
    printf ("============== YOUR STUFF ==============\n");
    printf ("Students:\n");
    printf ("THD: %d ", getStudents (g, player, STUDENT_THD));
    printf ("BPS: %d ", getStudents (g, player, STUDENT_BPS));
    printf ("BQN: %d ", getStudents (g, player, STUDENT_BQN));
    printf ("MJ: %d ", getStudents (g, player, STUDENT_MJ));
    printf ("MTV: %d ", getStudents (g, player, STUDENT_MTV));
    printf ("M$: %d\n", getStudents (g, player, STUDENT_MMONEY));
    printf ("Your current score:\n");
    printf ("KPI: %d ", getKPIpoints (g, player));
    printf ("Pubs: %d ", getPublications (g, player));
    printf ("IPs: %d\n", getIPs (g, player));
    printf ("Built:\n");
    printf ("ARCs: %d ", getARCs (g, player));
    printf ("Campuses: %d ", getCampuses (g, player));
    printf ("GO8s: %d\n", getGO8s (g, player));
    printf ("========================================\n");
}
Esempio n. 14
0
action decideAction (Game g) {

    action nextAction;
    int student[6];
    student[STUDENT_THD] = getStudents(g, getWhoseTurn(g), STUDENT_THD);
    student[STUDENT_BPS] = getStudents(g, getWhoseTurn(g), STUDENT_BPS);
    student[STUDENT_BQN] = getStudents(g, getWhoseTurn(g), STUDENT_BQN);
    student[STUDENT_MJ] = getStudents(g, getWhoseTurn(g), STUDENT_MJ);
    student[STUDENT_MTV] = getStudents(g, getWhoseTurn(g), STUDENT_MTV);
    student[STUDENT_MMONEY] = getStudents(g, getWhoseTurn(g),
                                          STUDENT_MMONEY);

    if(student[STUDENT_MJ] > 0  &&  student[STUDENT_MTV] > 0  &&
       student[STUDENT_MMONEY] > 0) {
        nextAction.actionCode = START_SPINOFF;
    } else {
        nextAction.actionCode = PASS;
    }

    return nextAction;
}
Esempio n. 15
0
// returns TRUE if it is legal for the current
// player to make the specified action, FALSE otherwise->
//
// "legal" means everything is legal:
//   * that the action code is a valid action code which is legal to
//     be made at this time
//   * that any path is well formed and legal ie consisting only of
//     the legal direction characters and of a legal length,
//     and which does not leave the island into the sea at any stage->
//   * that disciplines mentioned in any retraining actions are valid
//     discipline numbers, and that the university has sufficient
//     students of the correct type to perform the retraining
//
// eg when placing a campus consider such things as:
//   * is the path a well formed legal path
//   * does it lead to a vacent vertex?
//   * under the rules of the game are they allowed to place a
//     campus at that vertex?  (eg is it adjacent to one of their ARCs?)
//   * does the player have the 4 specific students required to pay for
//     that campus?
// It is not legal to make any action during Terra Nullis ie
// before the game has started->
// It is not legal for a player to make the moves OBTAIN_PUBLICATION
// or OBTAIN_IP_PATENT (they can make the move START_SPINOFF)
// you can assume that any pths passed in are NULL terminated strings->
int isLegalAction(Game g, action a) {
    int isLegal = TRUE;
    printf("Checking if an action is legal\n");
    int player = getWhoseTurn(g);
    int flag = 1;
    // Protect from stupid shit
    if ((a.actionCode < PASS) || (a.actionCode > RETRAIN_STUDENTS)) {
        printf("Invalid Action Code\n");
        flag = 0;
    } else if (a.actionCode == RETRAIN_STUDENTS) {
        printf("You've Called a retrain, checking if discipline");
        printf("within the bounds\n");
        // If it's a retrain action make sure the to
        // and from are in a nice range.
        if ((a.disciplineTo < STUDENT_THD)
            || (a.disciplineTo > STUDENT_MMONEY)) {
            printf("Invalid Discpline Code\n");
            flag = 0;
        }
        if ((a.disciplineFrom < STUDENT_THD)
            || (a.disciplineFrom > STUDENT_MMONEY)) {
            printf("Invalid Discpline Code\n");
            flag = 0;
        }
    }

    printf("The Flag when testing is %d\n", flag);

    if (flag == 1) {
        // Check all the basic stuff
        if (getTurnNumber(g) == TERRA_NULLIS) {
            isLegal = FALSE;
        } else if ((a.actionCode < 0) || (a.actionCode > MAX_ACTION)) {
            isLegal = FALSE;
        } else if ((getWhoseTurn(g) < 0) || (getWhoseTurn(g) > NUM_UNIS)) {
            isLegal = FALSE;
        } else if (a.actionCode == OBTAIN_IP_PATENT ||
            a.actionCode == OBTAIN_PUBLICATION) {
            isLegal = FALSE;
        }
        if (a.actionCode <= 3 && a.actionCode > 0 && isLegal) {
            if (validString(a.destination) == FALSE) {
                isLegal = FALSE;
            } else if (validPoint(pathToPoint(a.destination).x,
                pathToPoint(a.destination).y) == FALSE) {
                isLegal = FALSE;
            }
        }

        // edge actionEdge = pathToEdgeF (a.destination);

        // Check that someone can get an arc
        if (a.actionCode == OBTAIN_ARC && isLegal) {
            printf("Checking if the arc is legal. Arc:%s\n", a.destination);
            if (validNewEdge(g, pathToEdgeF(a.destination), player) == FALSE) {
                printf("Geographically Valid Edge\n");
                isLegal = FALSE;
            } else if (getStudents(g, player, STUDENT_BQN) < 1) {
                isLegal = FALSE;
            } else if (getStudents(g, player, STUDENT_BPS) < 1) {
                isLegal = FALSE;
            }
        }

        // Check that someone can get a Campus
        if (a.actionCode == BUILD_CAMPUS && isLegal) {
            if (validNewContents(g, a.destination, player) == FALSE) {
                isLegal = FALSE;
            } else if (getStudents(g, player, STUDENT_BQN) < 1) {
                isLegal = FALSE;
            } else if (getStudents(g, player, STUDENT_BPS) < 1) {
                isLegal = FALSE;
            } else if (getStudents(g, player, STUDENT_MJ) < 1) {
                isLegal = FALSE;
            } else if (getStudents(g, player, STUDENT_MTV) < 1) {
                isLegal = FALSE;
            }
        }

        if (a.actionCode == BUILD_GO8 && isLegal) {
            point actionPoint =  pathToPoint(a.destination);
            if (g->gameBoard->points[actionPoint.x][actionPoint.y]->contents !=
                player) {
                isLegal = FALSE;
            } else if (getStudents(g, player, STUDENT_MJ) < 2) {
                isLegal = FALSE;
            } else if (getStudents(g, player, STUDENT_MMONEY) < 3) {
                isLegal = FALSE;
            } else if (getTotalGO8s(g) == 8) {
                isLegal = FALSE;
            }
        }

        if (a.actionCode == START_SPINOFF && isLegal) {
            if (getStudents(g, player, STUDENT_MJ) < 1) {
                isLegal = FALSE;
            } else if (getStudents(g, player, STUDENT_MTV) < 1) {
                isLegal = FALSE;
            } else if (getStudents(g, player, STUDENT_MMONEY) < 1) {
                isLegal = FALSE;
            }
        }

        if (a.actionCode == RETRAIN_STUDENTS && isLegal) {
            int exchange = getExchangeRate(g, player, a.disciplineFrom,
                a.disciplineTo);
            if (getStudents(g, player, a.disciplineFrom) < exchange) {
                isLegal = FALSE;
            } else if (a.disciplineFrom == STUDENT_THD) {
                isLegal = FALSE;
            }
        }
    } else if (flag == 0) {
        isLegal = FALSE;
    }
    return isLegal;
}
Esempio n. 16
0
//Sample out testing simple things
void testInitialState(Game g){
   printf("Testing initialState!\n");
   int disciplines[] = DEFAULT_DISCIPLINES;
   int dice[] = DEFAULT_DICE;
   //Check each region produces correct disciplines
   int regionID = 0;
   while (regionID < NUM_REGIONS) {
      assert(getDiscipline(g,regionID) == disciplines[regionID]);
      regionID ++;
   }

   //Check what dice value produces students in the specified region
   regionID = 0;
   while (regionID < NUM_REGIONS) {
      assert(getDiceValue(g,regionID) == dice[regionID]);
      regionID ++;
   }

   assert(getMostARCs(g) == NO_ONE);
   assert(getMostPublications(g) == NO_ONE);
   assert(getTurnNumber(g) == -1);
   assert(getWhoseTurn(g) == NO_ONE);

   //Check individual uni values
   int uni = UNI_A;
   while(uni <= UNI_C){

      //Check Uni's exchange rates
      int testStudentFrom = STUDENT_BPS;
      int testStudentTo = STUDENT_BPS;
      while (testStudentFrom <= STUDENT_MMONEY) {
         while (testStudentTo <= STUDENT_MMONEY) {
            if (testStudentFrom != testStudentTo) {
               assert(getExchangeRate (g, uni, testStudentFrom, testStudentTo) == 3);
            }
            testStudentTo ++;
         }
         testStudentFrom ++;
         testStudentTo = STUDENT_BPS;
      }

      assert(getKPIpoints(g,uni) == 20);
      assert(getARCs(g,uni) == 0);
      assert(getGO8s(g,uni) == 0);
      assert(getCampuses(g,uni) == 2);
      assert(getPublications(g,uni) == 0);
      assert(getIPs(g,uni) == 0);

      //Check initial student values
      assert(getStudents(g,uni,STUDENT_THD)==0);
      assert(getStudents(g,uni,STUDENT_BPS)==3);
      assert(getStudents(g,uni,STUDENT_BQN)==3);
      assert(getStudents(g,uni,STUDENT_MJ)==1);
      assert(getStudents(g,uni,STUDENT_MTV)==1);
      assert(getStudents(g,uni,STUDENT_MMONEY)==1);

      uni++;
   }
   //Test isLegalAction at Terra Nullis
   action passAction;
   action CampusAction;
   action GO8Action;
   action ARCAction;
   action spinoffAction;
   action publicationAction;
   action patentAction;
   action retrainAction;
   passAction.actionCode = PASS;
   CampusAction.actionCode = BUILD_CAMPUS;
   GO8Action.actionCode = BUILD_GO8;
   ARCAction.actionCode = OBTAIN_ARC;
   spinoffAction.actionCode = START_SPINOFF;
   publicationAction.actionCode = OBTAIN_PUBLICATION;
   patentAction.actionCode = OBTAIN_IP_PATENT;
   retrainAction.actionCode = RETRAIN_STUDENTS;
   assert(isLegalAction(g, passAction) == FALSE);
   assert(isLegalAction(g, CampusAction) == FALSE);
   assert (isLegalAction(g, GO8Action) == FALSE);
   assert(isLegalAction(g, ARCAction) == FALSE);
   assert(isLegalAction(g, spinoffAction) == FALSE);
   assert(isLegalAction(g, publicationAction) == FALSE);
   assert(isLegalAction(g, patentAction) == FALSE);
   assert(isLegalAction(g, retrainAction) == FALSE);
   printf ("All initialState tests passed!\n");
}
Esempio n. 17
0
//Tests each action to see if they are legal, int isLegalAction (Game g, action a);
void testLegalAction(Game g, int player){
   printf("Testing isLegalAction!\n");
   action passAction;
   action CampusAction;
   action GO8Action;
   action ARCAction;
   action spinoffAction;
   action publicationAction;
   action patentAction;

   passAction.actionCode = PASS;
   CampusAction.actionCode = BUILD_CAMPUS;
   GO8Action.actionCode = BUILD_GO8;
   ARCAction.actionCode = OBTAIN_ARC;
   spinoffAction.actionCode = START_SPINOFF;
   publicationAction.actionCode = OBTAIN_PUBLICATION;
   patentAction.actionCode = OBTAIN_IP_PATENT;

   assert(isLegalAction(g, passAction) == TRUE);
   assert(isLegalAction(g, CampusAction) == TRUE &&
          getStudents(g, player, STUDENT_BPS) >= 1 &&
          getStudents(g, player, STUDENT_BQN) >= 1 &&
          getStudents(g, player, STUDENT_MJ) >= 1 &&
          getStudents(g, player, STUDENT_MTV) >= 1);
   assert((isLegalAction(g, CampusAction) == FALSE) &&
          ((getStudents(g, player, STUDENT_BPS) < 1) ||
          (getStudents(g, player, STUDENT_BQN) < 1) ||
          (getStudents(g, player, STUDENT_MJ) < 1) ||
          (getStudents(g, player, STUDENT_MTV) < 1)));

   assert (isLegalAction(g, GO8Action) == TRUE &&
          getStudents(g, player, STUDENT_MJ) >= 2 &&
          getStudents(g, player, STUDENT_MMONEY) >= 3);
   assert ((isLegalAction(g, GO8Action) == FALSE) &&
          ((getStudents(g, player, STUDENT_MJ) < 2) ||
          (getStudents(g, player, STUDENT_MMONEY) < 3)));

   assert(isLegalAction(g, ARCAction) == TRUE &&
          getStudents(g, player, STUDENT_BQN) >= 1 &&
          getStudents(g, player, STUDENT_BPS) >= 1);
   assert((isLegalAction(g, ARCAction) == FALSE) &&
         ((getStudents(g, player, STUDENT_BQN) < 1) ||
         (getStudents(g, player, STUDENT_BPS) < 1)));

   assert(isLegalAction(g, spinoffAction) == TRUE &&
          getStudents(g, player, STUDENT_MJ) >= 1 &&
          getStudents(g, player, STUDENT_MTV) >= 1 &&
          getStudents(g, player, STUDENT_MMONEY) >= 1);
   assert((isLegalAction(g, spinoffAction) == FALSE) &&
         ((getStudents(g, player, STUDENT_MJ) < 1) ||
         (getStudents(g, player, STUDENT_MTV) < 1) ||
         (getStudents(g, player, STUDENT_MMONEY) < 1)));

   assert(isLegalAction(g, publicationAction) == FALSE);
   assert(isLegalAction(g, patentAction) == FALSE);

   //Test Retrain_Students
   int testStudentFrom = STUDENT_BPS;
   int testStudentTo = STUDENT_BPS;
   action retrainAction;
   retrainAction.actionCode = RETRAIN_STUDENTS;
   retrainAction.disciplineFrom = testStudentFrom;
   retrainAction.disciplineTo = testStudentTo;
   while (testStudentFrom <= STUDENT_MMONEY) {
      while (testStudentTo <= STUDENT_MMONEY) {
         if (testStudentFrom != testStudentTo) {
            assert(isLegalAction(g, retrainAction) == TRUE &&
                   getStudents(g, player, testStudentFrom) - \
                   getExchangeRate (g, player, testStudentFrom, testStudentTo) >= 0);
         }
         testStudentTo ++;
         retrainAction.disciplineTo = testStudentTo;
      }
      testStudentFrom ++;
      retrainAction.disciplineFrom = testStudentFrom;
      retrainAction.disciplineTo = STUDENT_BPS;
   }
   printf ("All isLegalAction() tests passed!\n");
}
Esempio n. 18
0
int main(int argc, char *argv[]) {
   // miscellaneous
   /*int disciplines[NUM_REGIONS];
   int dice[NUM_REGIONS];*/
   Game g;
   
   // store the winner of each game
   int winner;
  
   // store game states within the game
   int keepPlaying;
   int turnFinished;
   int diceRollAmount;
   
   // random
   char *actions[] = ACTION_NAMES;
   int diceRoll;
   
   int passedTurns = 0;
            
   // seed rand!
   srand(time(NULL));
   
   // while the game is wanting to be played, create new game, etc.
   keepPlaying = TRUE;
   while (keepPlaying == TRUE) {
      // create the game
      //randomDisciplines(disciplines);
      //randomDice(dice);
      
      // you can change this to randomiseDisciplines() and randomiseDice() later
      int disciplines[NUM_REGIONS] = {CYAN,PURP,YELL,PURP,YELL,RED ,GREE,GREE, RED ,GREE,CYAN,YELL,CYAN,BLUE,YELL,PURP,GREE,CYAN,RED };
      int dice[NUM_REGIONS] = {9,10,8,12,6,5,3,7,3,11,4,6,4,9,9,2,8,10,5};

      // rig board like the real game
      rigBoard(disciplines, dice);
      g = newGame(disciplines, dice);
      
      printf("Game created! Now playing...\n");
      
      // start the game with noone as the winner
      winner = NO_ONE;
      while (winner == NO_ONE) {
         printLineBreak();
         // start new turn by setting turnFinished to false then
         // rolling the dice
         
         diceRollAmount = 0;
         diceRoll = 0;
         while (diceRollAmount < DICE_AMOUNT) {
            diceRoll += rollDice();
            diceRollAmount++;
         }
         
         throwDice(g, diceRoll);
         
         // new turn means new line break!
         printf("[Turn %d] The turn now belongs to University %c!\n", 
            getTurnNumber(g),
            getWhoseTurn(g) + UNI_CHAR_NAME);
         printf("The dice has casted a %d!\n", diceRoll);
         
         printf("\n");
         
         
         // keep going through the player's turn until
         // he/she decided to pass and finish the turn
         turnFinished = FALSE;
         while (turnFinished == FALSE && passedTurns < MAX_PASS) {
            // processes requests and all subrequests for a move and
            // checks if they are legal. only gives a move within the
            // scope of the defined actionCodes that is legal
            int turnPerson = getWhoseTurn(g);
            printf("Stats for %c:\n", turnPerson + UNI_CHAR_NAME);
            printf("KPIs: %d\n", getKPIpoints(g, turnPerson));
            printf("ARCs: %d\n", getARCs(g, turnPerson));
            printf("Campuses: %d\n", getCampuses(g, turnPerson));
            printf("GO8s: %d\n", getGO8s(g, turnPerson));
            printf("Publications: %d\n", 
               getPublications(g, turnPerson));
            printf("Patents: %d\n", 
               getIPs(g, turnPerson));
            int discipleIndex = 0;
            char *discipleNames[] = DISCIPLE_NAMES;
            while (discipleIndex < NUM_DISCIPLINES) {
               printf("Type %s: %d\n", discipleNames[discipleIndex],
                  getStudents(g, turnPerson, discipleIndex));
               discipleIndex++;
            } 
            printf("\n");
            
            action a = decideAction(g);
            
            // if not passing, make the move; otherwise end the turn
            if (a.actionCode == PASS) {
               turnFinished = TRUE;
               printf("You have passed onto the next person.\n");
            } else {
              
               // write what the player did, for a logs sake.
               printf("The action '%s' has being completed.\n", 
                       actions[a.actionCode]);
               if (a.actionCode == BUILD_CAMPUS 
                   || a.actionCode == OBTAIN_ARC 
                   || a.actionCode == BUILD_GO8) {
                  printf(" -> Destination: %s\n", a.destination);
               } else if (a.actionCode == RETRAIN_STUDENTS) {
                  printf(" -> DisciplineTo: %d\n", a.disciplineTo);
                  printf(" -> DisciplineFrom: %d\n", a.disciplineFrom);
               }

	        assert(isLegalAction(g, a));                                   
            
               // break this and the code dies. trololol!
               if (a.actionCode == START_SPINOFF) {
                  if (rand() % 3 <= 1) {
                     a.actionCode = OBTAIN_PUBLICATION;
                  } else {
                     a.actionCode = OBTAIN_IP_PATENT;               
                  }
               }

               makeAction(g, a);
               
               if (a.actionCode == PASS) {
                  passedTurns++;
               } else {
                  passedTurns = 0;
               }
               
               if (passedTurns >= MAX_PASS || getKPIpoints(g, turnPerson) >= WINNING_KPI) {
                  turnFinished = TRUE;
                  
               }
            }
            
            // if there is not a winner or pass, add a seperating line
            // to seperate actions being clumped together
            if (turnFinished == FALSE) {
               printf("\n");
            }
         }
         
         // check if there is a winner
         winner = checkForWinner(g);
      }
      
      if (passedTurns >= MAX_PASS) {
         printf("AI passes too much.\n");
         return EXIT_FAILURE;
      }
      
      printLineBreak();
      printf("GAME OVER!\n");
      printf("Vice Chanceller %c Won in %d Turns!!\n", 
             winner + UNI_CHAR_NAME,
             getTurnNumber(g));
             
      printf("\n");
      int counter = UNI_A;
      while (counter < NUM_UNIS + UNI_A) {
         printf("Uni %c scored %d KPIs\n", counter + UNI_CHAR_NAME,
                getKPIpoints(g, counter));
         counter++;
      }
      printLineBreak();
      
      disposeGame(g);
      
      // ask to play again
      printf("Ctrl+C will exit the game.\nOtherwise, the game will "
             "recommence by hitting enter.");
      int a = scanf("%*c");
      a++;
   }     
   
   return EXIT_SUCCESS;
}
Esempio n. 19
0
int enoughToStartSpinoff(Game g, int playerId) {
	int result = FALSE;

	int changesMade = TRUE;

	int conRateBPS = getExchangeRate(g, playerId, STUDENT_BPS, STUDENT_BPS);
	int conRateBQN = getExchangeRate(g, playerId, STUDENT_BQN, STUDENT_BQN);

	int numMJ = 0;
	int numMTV = 0;
	int numMMONEY = 0;

	while (changesMade && (numMTV < 1 || numMMONEY < 1 || numMJ < 1)) {

		int effectiveBPS = getStudents(g, playerId, STUDENT_BPS) / conRateBPS;
		int effectiveBQN = getStudents(g, playerId, STUDENT_BQN) / conRateBQN;
		numMJ = getStudents(g, playerId, STUDENT_MJ);
		numMTV = getStudents(g, playerId, STUDENT_MTV);
		numMMONEY = getStudents(g, playerId, STUDENT_MMONEY);

		if (numMJ < 1 || numMTV < 1 || numMMONEY < 1) {
			int toSide;

			if (numMJ < 1) {
				toSide = STUDENT_MJ;
			} else if (numMTV < 1) {
				toSide = STUDENT_MTV;
			} else {
				toSide = STUDENT_MMONEY;
			}

			changesMade = FALSE;

			if (effectiveBPS > 0) {
				changesMade = TRUE;
				convertStudents(g, STUDENT_BPS, toSide, 1);
			} else if (effectiveBQN > 0) {
				changesMade = TRUE;
				convertStudents(g, STUDENT_BQN, toSide, 1);
			}
		}
	}

	int conRateMTV = getExchangeRate(g, playerId, STUDENT_MTV, STUDENT_MTV);
	int conRateMJ = getExchangeRate(g, playerId, STUDENT_MJ, STUDENT_MJ);
	int conRateMMONEY = getExchangeRate(g, playerId, STUDENT_MMONEY, STUDENT_MMONEY);

	numMTV = getStudents(g, playerId, STUDENT_MTV);
	numMJ = getStudents(g, playerId, STUDENT_MJ);
	numMMONEY = getStudents(g, playerId, STUDENT_MMONEY);

	while (numMTV > numMJ && numMTV > numMMONEY && numMTV >= conRateMTV) {
		numMTV -= conRateMTV;

		if (numMJ < numMMONEY) {
			convertStudents(g, STUDENT_MTV, STUDENT_MJ, 1);
			numMJ++;
		} else {
			convertStudents(g, STUDENT_MTV, STUDENT_MMONEY, 1);
			numMMONEY++;
		}
	}

	while (numMJ > numMTV && numMJ > numMMONEY && numMJ >= conRateMJ) {
		numMJ -= conRateMJ;

		if (numMTV < numMMONEY) {
			convertStudents(g, STUDENT_MJ, STUDENT_MTV, 1);
			numMTV++;
		} else {
			convertStudents(g, STUDENT_MJ, STUDENT_MMONEY, 1);
			numMMONEY++;
		}
	}

	while (numMMONEY > numMJ && numMMONEY > numMTV && numMMONEY > conRateMMONEY) {
		numMMONEY -= conRateMMONEY;

		if (numMJ < numMTV) {
			convertStudents(g, STUDENT_MMONEY, STUDENT_MJ, 1);
			numMJ++;
		} else {
			convertStudents(g, STUDENT_MMONEY, STUDENT_MTV, 1);
			numMTV++;
		}
	}

	if (numMTV > 0 && numMJ > 0 && numMMONEY > 0) {
		result = TRUE;
	}

	return result;
}
Esempio n. 20
0
int enoughToBuildGO8(Game g, int playerId) {
	int result = FALSE;

	int changesMade = TRUE;

	int conRateBPS = getExchangeRate(g, playerId, STUDENT_BPS, STUDENT_BPS);
	int conRateBQN = getExchangeRate(g, playerId, STUDENT_BQN, STUDENT_BQN);
	int conRateMTV = getExchangeRate(g, playerId, STUDENT_MTV, STUDENT_MTV);

	int numRequiredMJ = 1;
	int numRequiredMMONEY = 1;

	while (changesMade && (numRequiredMJ > 0 || numRequiredMMONEY > 0)) {
		int effectiveBPS = getStudents(g, playerId, STUDENT_BPS) / conRateBPS;
		int effectiveBQN = getStudents(g, playerId, STUDENT_BQN) / conRateBQN;
		int numMJ = getStudents(g, playerId, STUDENT_MJ);
		int effectiveMTV = getStudents(g, playerId, STUDENT_MTV) / conRateMTV;
		int numMMONEY = getStudents(g, playerId, STUDENT_MMONEY);

		numRequiredMJ = 2 - numMJ;
		numRequiredMMONEY = 3 - numMMONEY;

		if (numRequiredMJ > 0 || numRequiredMMONEY > 0) {
			int toSide;

			if (numRequiredMJ < numRequiredMMONEY) {
				toSide = STUDENT_MMONEY;
			} else {
				toSide = STUDENT_MJ;
			}

			changesMade = FALSE;

			if (effectiveBPS > 0) {
				changesMade = TRUE;
				convertStudents(g, STUDENT_BPS, toSide, 1);
			} else if (effectiveBQN > 0) {
				changesMade = TRUE;
				convertStudents(g, STUDENT_BQN, toSide, 1);
			} else if (effectiveMTV > 0) {
				changesMade = TRUE;
				convertStudents(g, STUDENT_MTV, toSide, 1);
			}
		}
	}

	int numMMONEY = getStudents(g, playerId, STUDENT_MMONEY);
	int numMJ = getStudents(g, playerId, STUDENT_MJ);
	int conRateMMONEY = getExchangeRate(g, playerId, STUDENT_MMONEY, STUDENT_MMONEY);
	int conRateMJ = getExchangeRate(g, playerId, STUDENT_MJ, STUDENT_MJ);

	while (numMMONEY > numMJ && numMMONEY >= 3 + conRateMMONEY) {
		numMMONEY -= conRateMTV;
		convertStudents(g, STUDENT_MMONEY, STUDENT_MJ, 1);
		numMJ++;
	}

	while (numMJ > numMMONEY && numMJ >= 2 + conRateMTV && numMMONEY < 3) {
		numMJ -= conRateMJ;
		convertStudents(g, STUDENT_MJ, STUDENT_MMONEY, 1);
		numMMONEY++;
	}

	if (numRequiredMMONEY < 1 && numRequiredMJ < 1) {
		// printf("Required MMONEY: %d\n", numRequiredMMONEY);
		// printf("Required MJ: %d\n", numRequiredMJ);
		// printf("MMONEY: %d\n", getStudents(g, playerId, STUDENT_MMONEY));
		// printf("MJ: %d\n", getStudents(g, playerId, STUDENT_MJ));
		result = TRUE;
	}

	if (getGO8s(g, UNI_A) + getGO8s(g, UNI_B) + getGO8s(g, UNI_C) >= 8) {
		result = FALSE;
	}

	return result;
}
Esempio n. 21
0
action decideAction (Game g) {

        int me = getWhoseTurn (g);
        
        //Number of students resources
        int engineer = getStudents (g, me, STUDENT_BPS);
        int scientist = getStudents (g, me, STUDENT_BQN);
        int jobOwner = getStudents (g, me, STUDENT_MJ);
        int tvStar = getStudents (g, me, STUDENT_MTV);
        int moneyMaker = getStudents (g, me, STUDENT_MMONEY);
        
        //Exchange rate - Retraining Conditions
        //Last argument unnecessary as only disciplineFrom is important
        int costSci = getExchangeRate (g, me, STUDENT_BQN, STUDENT_MJ);
        int costEng = getExchangeRate (g, me, STUDENT_BPS, STUDENT_MJ);
        int costJob = \
            getExchangeRate (g, me, STUDENT_MJ, STUDENT_BPS);
        int costTv = getExchangeRate (g, me, STUDENT_MTV, STUDENT_BPS);
        int costMon = \
            getExchangeRate (g, me, STUDENT_MMONEY, STUDENT_BPS);
            
        //Possible actions to do:
        //Spinoffs -> 1 MJ + 1 MTV + 1 MMNY
        //Build ARCs -> 1 BPS + 1 BQN
        action nextAction;
        if (tvStar > costTv || jobOwner > costJob \
            || moneyMaker > costMon || scientist >= costSci \
            || engineer >= costEng) {
            // > to keep some MMONEY and MJOBS and MTVs,
            // to use for future spinoffs
            // >= to get rid of all BPS and BQNs
            
            nextAction.actionCode = RETRAIN_STUDENTS;
            //determine which student to retrain to
            if (jobOwner <= tvStar && jobOwner <= moneyMaker) {
                nextAction.disciplineTo = STUDENT_MJ;
            } else if (tvStar <= jobOwner && tvStar <= moneyMaker) {
                nextAction.disciplineTo = STUDENT_MTV;
            } else {
                nextAction.disciplineTo = STUDENT_MMONEY;
            }
            
            //Find out which student to retrain from
            /*Order is 
              MJ -> MTV -> MMONEY -> BQN -> BPS
              this ensures that BQN/BPS are retrained first*/ 
            if (jobOwner > costJob) {
                nextAction.disciplineFrom = STUDENT_MJ;
            } else if (tvStar > costTv) {
                nextAction.disciplineFrom = STUDENT_MTV;
            } else if (moneyMaker > costMon) {
                nextAction.disciplineFrom = STUDENT_MMONEY;
            } else if (scientist >= costSci) {
                nextAction.disciplineFrom = STUDENT_BQN;
            } else {
                nextAction.disciplineFrom = STUDENT_BPS;
            }
            
        } else if ((jobOwner * tvStar * moneyMaker) > 0) {
            //create a spinoff
            nextAction.actionCode = START_SPINOFF;
        } else {
            //no resources so end turn
            nextAction.actionCode = PASS;
        }
        
        return nextAction;
}
Esempio n. 22
0
static int tradeForCampus(Game g, int player, 
            int * disciplineFrom, int * disciplineTo) {
    int shouldWeTrade = TRUE;
    int canTradeBPS = FALSE;
    int canTradeBQN = FALSE;
    int canTradeMJ = FALSE;
    int canTradeMTV = FALSE;
    int canTradeMMONEY = FALSE;
    
    *disciplineFrom = 0;
    *disciplineTo = 0;
    
    int resourcesNeeded = 4;
    
    if (getStudents(g, player, STUDENT_BPS) >= 1 + getExchangeRate(g, player, STUDENT_BPS, 1)) {
        canTradeBPS = TRUE;
        if (getStudents(g,player,STUDENT_BPS) >= 1 + 2*getExchangeRate(g, player, STUDENT_BPS, 1)) {
            canTradeBPS++;
        }
    }
    if (getStudents(g, player, STUDENT_BQN) >= 1 + getExchangeRate(g, player, STUDENT_BQN, 1)) {
        canTradeBQN = TRUE;
        if (getStudents(g,player,STUDENT_BQN) >= 1 + 2*getExchangeRate(g, player, STUDENT_BQN, 1)) {
            canTradeBQN++;
        }
    }
    if (getStudents(g, player, STUDENT_MJ) >= 1 + getExchangeRate(g, player, STUDENT_MJ, 1)) {
        canTradeMJ = TRUE;
        if (getStudents(g,player,STUDENT_MJ) >= 1 + 2*getExchangeRate(g, player, STUDENT_MJ, 1)) {
            canTradeMJ++;
        }
    }
    if (getStudents(g, player, STUDENT_MTV) >= 1 + getExchangeRate(g, player, STUDENT_MTV, 1)) {
        canTradeMTV = TRUE;
    }
    if (getStudents(g, player, STUDENT_MMONEY) >= getExchangeRate(g, player, STUDENT_MMONEY, 1)) {
        canTradeMMONEY = TRUE;
    }
    
    if (getStudents(g, player, STUDENT_BQN)) {
        resourcesNeeded--;
    }
    if (getStudents(g, player, STUDENT_BPS)) {
        resourcesNeeded--;
    }
    if (getStudents(g, player, STUDENT_MTV)) {
        resourcesNeeded--;
    }
    if (getStudents(g, player, STUDENT_MJ)) {
        resourcesNeeded--;
    }    
    
    if (resourcesNeeded < canTradeBPS + canTradeBQN +
         canTradeMJ + canTradeMTV + canTradeMMONEY) {
        if (getStudents(g, player, STUDENT_MJ) == FALSE) {
            *disciplineTo = STUDENT_MJ;
        } else if (getStudents(g, player, STUDENT_BQN) == FALSE) {
            *disciplineTo = STUDENT_BQN;
        } else if (getStudents(g, player, STUDENT_BPS) == FALSE) {
            *disciplineTo = STUDENT_BPS;
        } else if (getStudents(g, player, STUDENT_MTV) == FALSE) {
            *disciplineTo = STUDENT_MTV;
        }
        if (canTradeMMONEY) {
            *disciplineFrom = STUDENT_MMONEY;
        } else if (canTradeMTV) {
            *disciplineFrom = STUDENT_MTV;
        }  else if (canTradeMJ) {
            *disciplineFrom = STUDENT_MJ;
        
        } else if (canTradeBQN) {
            *disciplineFrom = STUDENT_BQN;
        
        } else if (canTradeBPS) {
            *disciplineFrom = STUDENT_BPS;
        }
    
    } else {
        shouldWeTrade = FALSE;
    }
    return shouldWeTrade;        
}
Esempio n. 23
0
// NOTE:  IS MAKEACTION(g, PASS_ACTION) required to end turn?  or just THROWDICE?
// Unsure on this, might ahve to ask a tutor.
void testStudentAllocationAndMakeAction (void) {

    printf ("Now testing updating of students after dice throws and actions.\n");

    // Create game:
    int disciplines[] = DEFAULT_DISCIPLINES;
    int dice[] = DEFAULT_DICE;
    Game g = newGame (disciplines, dice);

    // Throw the dice once, not giving any players students, to move the
    // current turn to '0' rather than '-1':
    throwDice(g, 3);

    // Allocate 300 students to each player through numerous dice throws!
    int throws = 0;
    while (throws < 150) {

        // Trigger each hexagon with an adjoined campus:

        throwDice(g, 11); // 1 MTV to player 1
        throwDice(g, 6);  // 1 MJ to player 1

        throwDice(g, 9); // 1 BQN to player 2
        throwDice(g, 9); // 1 BQN to player 2
        throwDice(g, 9); // 1 BQN to player 2
        throwDice(g, 5); // 1 BPS to player 2
        throwDice(g, 5); // 1 BPS to player 2
        throwDice(g, 5); // 1 BPS to player 2

        throwDice(g, 8); // 1 MJ and 1 MTV to player 3
    }

    /* At this point:
     *  - Turn number is [150 * 9 = ] 1350
     *  - Number of turns mod 3 is 0, therefore player 1's (UNI_A) turn to roll.
     *  - Player 1 has 150 MJs and 150 MTVs
     *  - Player 2 has 450 BQNs and 450 BPSs
     *  - Player 3 has 150 MJs and 150 MTVs
    */

    // Ensure game state has been updated correctly:

    printf ("Ensuring 'getTurnNumber' and 'getWhoseTurn' return correct values.\n");
    assert (getTurnNumber(g) == 750);
    assert (getWhoseTurn(g) == UNI_A);

    printf ("Ensuring UNI_A has been allocated the correct number of players.\n");
    assert (getStudents(g, UNI_A, STUDENT_BPS)    == 0);
    assert (getStudents(g, UNI_A, STUDENT_BQN)    == 0);
    assert (getStudents(g, UNI_A, STUDENT_MJ)     == 150);
    assert (getStudents(g, UNI_A, STUDENT_MTV)    == 150);
    assert (getStudents(g, UNI_A, STUDENT_MMONEY) == 0);
    assert (getStudents(g, UNI_A, STUDENT_THD)    == 0);

    printf ("Ensuring UNI_B has been allocated the correct number of players.\n");
    assert (getStudents(g, UNI_B, STUDENT_BPS)    == 450);
    assert (getStudents(g, UNI_B, STUDENT_BQN)    == 450);
    assert (getStudents(g, UNI_B, STUDENT_MJ)     == 0);
    assert (getStudents(g, UNI_B, STUDENT_MTV)    == 0);
    assert (getStudents(g, UNI_B, STUDENT_MMONEY) == 0);
    assert (getStudents(g, UNI_B, STUDENT_THD)    == 0);

    printf ("Ensuring UNI_C has been allocated the correct number of players.\n");
    assert (getStudents(g, UNI_C, STUDENT_BPS)    == 0);
    assert (getStudents(g, UNI_C, STUDENT_BQN)    == 0);
    assert (getStudents(g, UNI_C, STUDENT_MJ)     == 150);
    assert (getStudents(g, UNI_C, STUDENT_MTV)    == 150);
    assert (getStudents(g, UNI_C, STUDENT_MMONEY) == 0);
    assert (getStudents(g, UNI_C, STUDENT_THD)    == 0);



    // Convert UNI_B's BQNs and BPSs into MJs and MTVs, so that each
    // UNI has the same numbers of students:
    printf ("Testing basic student conversion.\n");

    // Move turn to UNI_B from UNI_A (without giving the UNIs students):
    throwDice(g, 3);

    action convertStudents;
    convertStudents.actionCode = RETRAIN_STUDENTS;

    // Convert BPSs into MJs:
    convertStudents.disciplineFrom = STUDENT_BPS;
    convertStudents.disciplineTo = STUDENT_MJ;

    int numConversions = 0;
    while (numConversions < 150) {
        makeAction(g, convertStudents);
    }

    // Ensure the counts have been updated correctly:
    assert (getStudents(g, UNI_B, STUDENT_BPS) == 0);
    assert (getStudents(g, UNI_B, STUDENT_MJ)  == 150);


    // Convert BQNs into MTVs:
    convertStudents.disciplineFrom = STUDENT_BQN;
    convertStudents.disciplineTo = STUDENT_MTV;

    int numConversions = 0;
    while (numConversions < 150) {
        makeAction(g, convertStudents);
    }

    // Ensure the counts have been updated correctly:
    assert (getStudents(g, UNI_B, STUDENT_BQN) == 0);
    assert (getStudents(g, UNI_B, STUDENT_MTV) == 150);


    // Now each UNI has 150 MTVs and 150 MJs.

    // Set turn to UNI_A:
    throwDice(g, 3); // Now UNI_C's turn
    throwDice(g, 3); // Now UNI_A's turn



    // Get each UNI to perform path-based and path-less actions:
    int activeUNI = UNI_A;
    while (activeUNI != NO_ONE) {

        action testAction;

        testAction.actionCode = PASS


        // Set activeUNI to the next UNI
        // Note: incrementing not used because the values of the
        //       constants are not guaranteed.
        throwDice(g, 3);
        if (activeUNI == UNI_A) {
            activeUNI = UNI_B;
        } else if (activeUNI == UNI_B) {
            activeUNI = UNI_C;
        } else {
            activeUNI = NO_ONE;
        }
    }



    disposeGame (g);
    printf ("Passed\n");
}
Esempio n. 24
0
int main (int argc, char * argv[]) {

	int disciplines[19] = {STUDENT_BQN, STUDENT_MMONEY, STUDENT_MJ, \
		STUDENT_MMONEY, STUDENT_MJ, STUDENT_BPS, STUDENT_MTV, \
		STUDENT_MTV, STUDENT_BPS,STUDENT_MTV, STUDENT_BQN, \
		STUDENT_MJ, STUDENT_BQN, STUDENT_THD, STUDENT_MJ, \
		STUDENT_MMONEY, STUDENT_MTV, STUDENT_BQN, STUDENT_BPS};

	int dice[19] = {9,10,8,12,6,5,3,11,3,11,4,6,4,7,9,2,8,10,5};

	Game g = newGame (disciplines, dice);
	action a;
//	int score = 0; //This stores the KPI points of current player 
	int curPlayer = NO_ONE; 
	int curTurn = 0; 
	int playerKPI = 0;
	int numStudents[MAX_STU_TYPES];
	int legal = 0;
	int diceScore = 0; 
	int spinoffDice = 0;
	//int discipline = 0;
	int counter = 0; 

	char *degrees[] = \
		  {"THDs", "BPSs", "BQNs", "MJs", "MTVs", "MMONEYs"};
	


	printf ("New game created, variables are initialized.\n");
	printf ("Let the game begin!\n\n");

	while (playerKPI < MAX_KPIPTS) {
		
		//To simulate an actual real life dice, we throw two dice 
		diceScore = rollDice();
		throwDice (g, diceScore);

		curTurn = getTurnNumber (g);
		curPlayer = getWhoseTurn (g);
		printf ("Turn number: %d\n", curTurn);
		printf ("Player %d's turn. Rolling dice.\n", curPlayer);
		printf ("The two dice rolled a %d! \n", diceScore);

		printf ("You currently have: \n");
		counter = 0;
		while (counter < MAX_STU_TYPES) {
			numStudents[counter] = getStudents (g, curPlayer, counter);
			printf ("    %d: %s\n", numStudents[counter],\
								    degrees[counter]);
			counter ++;
		}
		actionOptions ();
		a = actionPrompt (g);
		legal = isLegalAction (g, a);

		while (a.actionCode != PASS) {
			while (legal == FALSE) {
				printf ("The chosen action is illegal, try again.\n");
				actionPrompt (g);
				legal = isLegalAction (g, a);
			}

			if (a.actionCode == START_SPINOFF) {
				//Ensures dice returns 1, 2 or 3.
				spinoffDice = (rand()%3 + 1);
				if (spinoffDice == 1) {
					a.actionCode = OBTAIN_IP_PATENT;
				} else {
					a.actionCode = OBTAIN_PUBLICATION;
				}
			}

			makeAction (g, a);
			printf("Action made!");

			printf ("Your current stats:\n");
			printf ("    ARC Grants: %d\n", getARCs (g, curPlayer));
			printf ("    No of Campuses: %d\n", getCampuses (g, curPlayer));
			printf ("    No of G08s: %d\n", getGO8s (g, curPlayer));
			printf ("    No of Pubs: %d\n", getPublications (g, curPlayer));
			printf ("    No of IP Patents: %d\n", getIPs (g, curPlayer));

			playerKPI = getKPIpoints (g, curPlayer);
			printf ("Player %d KPI Score: %d\n\n", curPlayer, playerKPI);
		}

		printf ("Next player's turn.\n\n");

	}

	printf ("Congratulations, player %d won.\n", curPlayer);
	printf ("Game completed. Disposing game.\n");
	
	disposeGame (g);

	return EXIT_SUCCESS;
}
Esempio n. 25
0
static int tradeForSpinOff(Game g, int player, 
            int * disciplineFrom, int * disciplineTo) {
    int shouldWeTrade = TRUE;
    
    //if we have enough of the students to trade 
    //and still build a spinoff
    int canTradeBPS = FALSE;
    int canTradeBQN = FALSE;
    int canTradeMJ = FALSE;
    int canTradeMTV = FALSE;
    int canTradeMMONEY = FALSE;
    
    *disciplineFrom = 0;
    *disciplineTo = 0;
    
    //the total amount of resources for a spinoff
    int resourcesNeeded = 3; 
    
    if (getStudents(g, player, STUDENT_BPS) >= getExchangeRate(g, player, STUDENT_BPS, 1)) {
        canTradeBPS = TRUE;
        if (getStudents(g, player, STUDENT_BPS) >= 2*getExchangeRate(g, player, STUDENT_BPS, 1)) {
            canTradeBPS++;
        }
    }
    if (getStudents(g, player, STUDENT_BQN) >= getExchangeRate(g, player, STUDENT_BQN, 1)) {
        canTradeBQN = TRUE;
        if (getStudents(g, player, STUDENT_BQN) >= 2*getExchangeRate(g, player, STUDENT_BQN, 1)) {
            canTradeBQN++;
        }
    }
    
    //these are >= 4 since these resources are used for
    //building spinoffs
    if (getStudents(g, player, STUDENT_MJ) >= 1 + getExchangeRate(g, player, STUDENT_MJ, 1)) {
        canTradeMJ = TRUE;
        if (getStudents(g, player, STUDENT_MJ) >= 1 + 2*getExchangeRate(g, player, STUDENT_MJ, 1)) {
            canTradeMJ++;
        }
    }
    if (getStudents(g, player, STUDENT_MTV) >= 1 + getExchangeRate(g, player, STUDENT_MTV, 1)) {
        canTradeMTV = TRUE;
    }
    if (getStudents(g, player, STUDENT_MMONEY) >= 1 + getExchangeRate(g, player, STUDENT_MMONEY, 1)) {
        canTradeMMONEY = TRUE;
    }
    
    
    //so if we have these resources,
    //we can decrement the amount we need to trade for
    if (getStudents(g, player, STUDENT_MMONEY)) {
        resourcesNeeded--;
    }
    if (getStudents(g, player, STUDENT_MTV)) {
        resourcesNeeded--;
    }
    if (getStudents(g, player, STUDENT_MJ)) {
        resourcesNeeded--;
    }
    
    //if we can trade enough of the extra resources 
    //to get the resources needed for a spinoff
    if (resourcesNeeded < canTradeBPS + canTradeBQN +
         canTradeMJ + canTradeMTV + canTradeMMONEY) {
        //if we dont have these resources that we need
        if (getStudents(g, player, STUDENT_MJ) == FALSE) {
            *disciplineTo = STUDENT_MJ;
        } else if (getStudents(g, player, STUDENT_MTV) == FALSE) {
            *disciplineTo = STUDENT_MTV;
        } else if (getStudents(g, player, STUDENT_MMONEY) == FALSE) {
            *disciplineTo = STUDENT_MMONEY;
        }
        //these are the resources that we can trade
        if (canTradeMMONEY) {
            *disciplineFrom = STUDENT_MMONEY;
        } else if (canTradeMTV) {
            *disciplineFrom = STUDENT_MTV;
        }  else if (canTradeMJ) {
            *disciplineFrom = STUDENT_MJ;
        
        } else if (canTradeBQN) {
            *disciplineFrom = STUDENT_BQN;
        
        } else if (canTradeBPS) {
            *disciplineFrom = STUDENT_BPS;
        }
    
    } else {
        shouldWeTrade = FALSE;
    }
    return shouldWeTrade;
               
}
Esempio n. 26
0
int enoughToBuildCampus(Game g, int playerId, fromToArc arcPath[2]) {
	int result = FALSE;

	int pathResources = 2;

	if (arcPath[0].alreadyOwned) {
		pathResources--;
	}

	if (arcPath[1].alreadyOwned) {
		pathResources--;
	}

	int conRateBPS = getExchangeRate(g, playerId, STUDENT_BPS, STUDENT_BPS);
	int conRateBQN = getExchangeRate(g, playerId, STUDENT_BPS, STUDENT_BQN);
	int conRateMJ = getExchangeRate(g, playerId, STUDENT_BPS, STUDENT_MJ);
	int conRateMTV = getExchangeRate(g, playerId, STUDENT_BPS, STUDENT_MTV);
	int conRateMMONEY = getExchangeRate(g, playerId, STUDENT_BPS, STUDENT_MMONEY);

	int numBPS = getStudents(g, playerId, STUDENT_BPS);
	int numBQN = getStudents(g, playerId, STUDENT_BQN);
	int numMJ = getStudents(g, playerId, STUDENT_MJ);
	int numMTV = getStudents(g, playerId, STUDENT_MTV);
	int numMMONEY = getStudents(g, playerId, STUDENT_MMONEY);

	if (numMTV < 1) {
		if (numBPS - conRateBPS >= pathResources + 1) {
			convertStudents(g, STUDENT_BPS, STUDENT_MTV, 1);
			numBPS = numBPS - conRateBPS;
			numMTV++;
		} else if (numBQN - conRateBQN >= pathResources + 1) {
			convertStudents(g, STUDENT_BQN, STUDENT_MTV, 1);
			numBQN = numBQN - conRateBQN;
			numMTV++;
		} else if (numMJ - conRateMJ >= 1) {
			convertStudents(g, STUDENT_MJ, STUDENT_MTV, 1);
			numMJ = numMJ - conRateMJ;
			numMTV++;
		}
	}

	if (numMJ < 1) {
		if (numBPS - conRateBPS >= pathResources + 1) {
			convertStudents(g, STUDENT_BPS, STUDENT_MJ, 1);
			numBPS = numBPS - conRateBPS;
			numMJ++;
		}
		else if (numBQN - conRateBQN >= pathResources + 1) {
			convertStudents(g, STUDENT_BQN, STUDENT_MJ, 1);
			numBQN = numBQN - conRateBQN;
			numMJ++;
		}
		else if (numMTV - conRateMTV >= 1) {
			convertStudents(g, STUDENT_MTV, STUDENT_MJ, 1);
			numMTV = numMTV - conRateMTV;
			numMJ++;
		}
	}

	if (numBQN <= pathResources) {
		int neededBQN = pathResources + 1 - numBQN;
		if (numBPS - (conRateBPS * neededBQN) >= pathResources + 1) {
			convertStudents(g, STUDENT_BPS, STUDENT_BQN, neededBQN);
			numBPS = numBPS - (conRateBPS * (pathResources + 1));
			numBQN += neededBQN;
		}
		else if (numMJ - (conRateBQN * neededBQN) >= 1) {
			convertStudents(g, STUDENT_MJ, STUDENT_BQN, neededBQN);
			numMJ = numMJ - (conRateBQN * (pathResources + 1));
			numBQN += neededBQN;
		}
		else if (numMTV - (conRateBQN * neededBQN) >= 1) {
			convertStudents(g, STUDENT_MTV, STUDENT_BQN, neededBQN);
			numMTV = numMTV - (conRateBQN * (pathResources + 1));
			numBQN += neededBQN;
		}
	}

	if (numBPS <= pathResources) {
		int neededBPS = pathResources + 1 - numBPS;
		if (numBQN - (conRateBQN * neededBPS) >= pathResources + 1) {
			convertStudents(g, STUDENT_BQN, STUDENT_BPS, neededBPS);
			numBQN = numBQN - (conRateBQN * (pathResources + 1));
			numBPS += neededBPS;
		} else if (numMJ - (conRateMJ * neededBPS) >= 1) {
			convertStudents(g, STUDENT_MJ, STUDENT_BPS, neededBPS);
			numMJ = numMJ - (conRateMJ * (pathResources + 1));
			numBPS += neededBPS;
		} else if (numMTV - (conRateMTV * neededBPS) >= 1) {
			convertStudents(g, STUDENT_MTV, STUDENT_BPS, neededBPS);
			numMTV = numMTV - (conRateMTV * (pathResources + 1));
			numBPS += neededBPS;
		}
	}

	while (numMJ <= numBQN - 1 && numMJ <= numBPS - 1 && numMTV > 1) {
		convertStudents(g, STUDENT_MTV, STUDENT_MJ, 1);
		numMTV -= conRateMTV;
		numMJ++;
	}

	while (numBPS <= numBQN - 1 && numBPS <= numMJ - 1 && numMTV > 1) {
		convertStudents(g, STUDENT_MTV, STUDENT_BPS, 1);
		numMTV -= conRateMTV;
		numBPS++;
	}

	while(numBQN <= numBPS - 1 && numBQN <= numMJ - 1 && numMTV > 1) {
		convertStudents(g, STUDENT_MTV, STUDENT_BQN, 1);
		numMTV -= conRateMTV;
		numBQN++;
	}

	while (numMJ <= numBQN - 1 && numMJ <= numBPS - 1 && numMMONEY > 1) {
		convertStudents(g, STUDENT_MMONEY, STUDENT_MJ, 1);
		numMMONEY -= conRateMMONEY;
		numMJ++;
	}

	while (numBPS <= numBQN - 1 && numBPS <= numMJ - 1 && numMMONEY > 1) {
		convertStudents(g, STUDENT_MMONEY, STUDENT_BPS, 1);
		numMMONEY -= conRateMMONEY;
		numBPS++;
	}

	while(numBQN <= numBPS - 1 && numBQN <= numMJ - 1 && numMMONEY > 1) {
		convertStudents(g, STUDENT_MMONEY, STUDENT_BQN, 1);
		numMMONEY -= conRateMMONEY;
		numBQN++;
	}

	if (getStudents(g, playerId, STUDENT_BPS) >= pathResources + 1 &&
		getStudents(g, playerId, STUDENT_BQN) >= pathResources + 1 &&
		getStudents(g, playerId, STUDENT_MJ) >= 1 &&
		getStudents(g, playerId, STUDENT_MTV) >= 1) {
		result = TRUE;
	}

	return result;
}
Esempio n. 27
0
void testInitialisation (Game testGame){
   
   action testAction;
   
   printf ("Testing initial conditions.\n");
   
   printf ("Testing getDiscipline.\n");
   assert (getDiscipline(testGame, 0) == STUDENT_BQN);
   assert (getDiscipline(testGame, 1) == STUDENT_MMONEY);
   assert (getDiscipline(testGame, 2) == STUDENT_MJ);
   assert (getDiscipline(testGame, 3) == STUDENT_MMONEY);
   assert (getDiscipline(testGame, 4) == STUDENT_MJ);
   assert (getDiscipline(testGame, 5) == STUDENT_BPS);
   assert (getDiscipline(testGame, 6) == STUDENT_MTV);
   assert (getDiscipline(testGame, 7) == STUDENT_MTV);
   assert (getDiscipline(testGame, 8) == STUDENT_BPS);
   assert (getDiscipline(testGame, 9) == STUDENT_MTV);
   assert (getDiscipline(testGame, 10) == STUDENT_BQN);
   assert (getDiscipline(testGame, 11) == STUDENT_MJ);
   assert (getDiscipline(testGame, 12) == STUDENT_BQN);
   assert (getDiscipline(testGame, 13) == STUDENT_THD);
   assert (getDiscipline(testGame, 14) == STUDENT_MJ);
   assert (getDiscipline(testGame, 15) == STUDENT_MMONEY);
   assert (getDiscipline(testGame, 16) == STUDENT_MTV);
   assert (getDiscipline(testGame, 17) == STUDENT_BQN);
   assert (getDiscipline(testGame, 18) == STUDENT_BPS);
   
   printf ("Testing getDiceValue\n");
   assert (getDiceValue(testGame, 0) == 9);
   assert (getDiceValue(testGame, 1) == 10);
   assert (getDiceValue(testGame, 2) == 8);
   assert (getDiceValue(testGame, 3) == 12);
   assert (getDiceValue(testGame, 4) == 6);
   assert (getDiceValue(testGame, 5) == 5);
   assert (getDiceValue(testGame, 6) == 3);
   assert (getDiceValue(testGame, 7) == 11);
   assert (getDiceValue(testGame, 8) == 3);
   assert (getDiceValue(testGame, 9) == 11);
   assert (getDiceValue(testGame, 10) == 4);
   assert (getDiceValue(testGame, 11) == 6);
   assert (getDiceValue(testGame, 12) == 4);
   assert (getDiceValue(testGame, 13) == 7);
   assert (getDiceValue(testGame, 14) == 9);
   assert (getDiceValue(testGame, 15) == 2);
   assert (getDiceValue(testGame, 16) == 8);
   assert (getDiceValue(testGame, 17) == 10);
   assert (getDiceValue(testGame, 18) == 5);
   
   printf ("Testing Most ARC\n");
   assert (getMostARCs(testGame) == NO_ONE);
   
   printf ("Testing most publications\n");
   assert (getMostPublications (testGame) == NO_ONE);
   
   printf ("Testing turnNumber\n");
   assert (getTurnNumber(testGame) == -1);
   
   printf ("Testing whoseTurn.\n");
   assert (getWhoseTurn (testGame) == NO_ONE);

   printf("Testing getCampus (content of given vertex) \n");
   assert (getCampus (testGame, "RLBLR") == VACANT_VERTEX);
   assert (getCampus (testGame, "RLBBR") == VACANT_VERTEX);
   assert (getCampus (testGame, "LRL") == VACANT_VERTEX);
   
   printf("Testing getARC (content of given edge) \n");
   assert (getARC (testGame, "L") == VACANT_ARC);
   assert (getARC (testGame, "R") == VACANT_ARC);
   assert (getARC (testGame, "LR") == VACANT_ARC);
   assert (getARC (testGame, "RR") == VACANT_ARC);
   
   printf ("Testing isLegalAction\n");
   assert (isLegalAction (testGame, testAction) == FALSE);
   
   printf ("Testing KPI points\n");
   assert (getKPIpoints (testGame, UNI_A) == 0);
   assert (getKPIpoints (testGame, UNI_B) == 0);
   assert (getKPIpoints (testGame, UNI_C) == 0);
   
   printf ("Testing getARCs (number of ARC grants) \n");
   assert (getARCs (testGame, UNI_A) == 0);
   assert (getARCs (testGame, UNI_B) == 0);
   assert (getARCs (testGame, UNI_C) == 0);
   
   printf ("Testing GO8 (number of G08 campus) \n");
   assert (getGO8s (testGame, UNI_A) == 0);
   assert (getGO8s (testGame, UNI_B) == 0);
   assert (getGO8s (testGame, UNI_C) == 0);
   
   printf ("Testing getCampuses (number of normal campuses)\n");
   assert (getCampuses (testGame, UNI_A) == 2);
   assert (getCampuses (testGame, UNI_B) == 2);
   assert (getCampuses (testGame, UNI_C) == 2);
   
   printf ("Testing IPs (number of IP patent) \n");
   assert (getIPs(testGame, UNI_A) == 0);
   assert (getIPs(testGame, UNI_B) == 0);
   assert (getIPs(testGame, UNI_C) == 0);
   
   printf ("Testing publications\n");
   assert (getPublications(testGame, UNI_A) == 0);
   assert (getPublications(testGame, UNI_B) == 0);
   assert (getPublications(testGame, UNI_C) == 0);
 
   printf ("Testing number of students of UNI_A\n");
   assert (getStudents (testGame, UNI_A, STUDENT_THD) == 0);
   assert (getStudents (testGame, UNI_A, STUDENT_BPS) == 3);
   assert (getStudents (testGame, UNI_A, STUDENT_BQN) == 3);
   assert (getStudents (testGame, UNI_A, STUDENT_MJ) == 1);
   assert (getStudents (testGame, UNI_A, STUDENT_MTV) == 1);
   assert (getStudents (testGame, UNI_A, STUDENT_MMONEY) == 1);

   printf ("Testing number of students of UNI_B\n");
   assert (getStudents (testGame, UNI_B, STUDENT_THD) == 0);
   assert (getStudents (testGame, UNI_B, STUDENT_BPS) == 3);
   assert (getStudents (testGame, UNI_B, STUDENT_BQN) == 3);
   assert (getStudents (testGame, UNI_B, STUDENT_MJ) == 1);
   assert (getStudents (testGame, UNI_B, STUDENT_MTV) == 1);
   assert (getStudents (testGame, UNI_B, STUDENT_MMONEY) == 1);
   
   printf ("Testing number of students of UNI_C\n");
   assert (getStudents (testGame, UNI_C, STUDENT_THD) == 0);
   assert (getStudents (testGame, UNI_C, STUDENT_BPS) == 3);
   assert (getStudents (testGame, UNI_C, STUDENT_BQN) == 3);
   assert (getStudents (testGame, UNI_C, STUDENT_MJ) == 1);
   assert (getStudents (testGame, UNI_C, STUDENT_MTV) == 1);
   assert (getStudents (testGame, UNI_C, STUDENT_MMONEY) == 1);
   

   printf ("Testing getExchangeRate for UNI_A\n");
   assert (getExchangeRate (testGame, UNI_A, STUDENT_BPS, STUDENT_BPS) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_BPS, STUDENT_BQN) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_BPS, STUDENT_MJ) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_BPS, STUDENT_MTV) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_BPS, STUDENT_MMONEY) == 3);
   
   assert (getExchangeRate (testGame, UNI_A, STUDENT_MMONEY, STUDENT_MMONEY) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_MMONEY, STUDENT_BPS) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_MMONEY, STUDENT_BQN) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_MMONEY, STUDENT_MJ) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_MMONEY, STUDENT_MTV) == 3);
   
   assert (getExchangeRate (testGame, UNI_A, STUDENT_MTV, STUDENT_MTV) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_MTV, STUDENT_BPS) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_MTV, STUDENT_BQN) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_MTV, STUDENT_MJ) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_MTV, STUDENT_MMONEY) == 3);
   
   assert (getExchangeRate (testGame, UNI_A, STUDENT_BQN, STUDENT_BQN) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_BQN, STUDENT_BPS) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_BQN, STUDENT_MJ) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_BQN, STUDENT_MTV) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_BQN, STUDENT_MMONEY) == 3);
   
   assert (getExchangeRate (testGame, UNI_A, STUDENT_MJ, STUDENT_MJ) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_MJ, STUDENT_BPS) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_MJ, STUDENT_BQN) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_MJ, STUDENT_MTV) == 3);
   assert (getExchangeRate (testGame, UNI_A, STUDENT_MJ, STUDENT_MMONEY) == 3);
  
   printf ("All tests passed\n\n");
   
   
}
Esempio n. 28
0
int main(int argc, char *argv[]) {
    int disciplines[] = DEFAULT_DISCIPLINES;
    disciplines[2] = STUDENT_BPS;
    disciplines[7] = STUDENT_BPS;
    disciplines[11] = STUDENT_BQN;
    disciplines[16] = STUDENT_BQN;
    int dice[] = DEFAULT_DICE;
    int i = 0;
    int automation = TRUE;
    int diceRoll = 1;
    char *vertices[54];
    char *sides[72];

    //nanosecond seeding
    struct timespec ts;
    clock_gettime(CLOCK_MONOTONIC, &ts);

    populatePaths(vertices);
    populateSides(sides);

    printf("Automatic(1) or Human(0): ");
    scanf("%d", &automation);

    //seeding starts now
    srand((time_t)ts.tv_nsec);

    Game g = newGame(disciplines, dice);
    action a;

    while(getKPILeader(g) < 150  &&  getTurnNumber(g) < 9003) {
        if(automation == FALSE) {
            printf("Enter dice roll: ");
            scanf("%d", &diceRoll);
        } else {
            diceRoll = rand() % 10 + 2;
        }

        throwDice(g, diceRoll);
        printf("diceRoll = %d\n", diceRoll);

        printf("\n");
        printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
        printf("Turn: %d\n", getTurnNumber(g));
        printf("Player %d's turn\n", getWhoseTurn(g));

        printf("\n");
        printf("You have %d ARCs\n", getARCs(g, getWhoseTurn(g)));
        i = 0;
        while(i < 72) {
            if(getARC(g, sides[i]) == getWhoseTurn(g)) { 
                printf("You have an ARC on %s\\0\n", sides[i]);
            }
            i++;
        }
        printf("You have %d Campuses\n", getCampuses(g, getWhoseTurn(g)));
        printf("You have %d GO8s\n", getGO8s(g, getWhoseTurn(g)));
        i = 0;
        while(i < 54) {
            if(getCampus(g, vertices[i]) == getWhoseTurn(g)) { 
                printf("You have a campus on %s\\0\n", vertices[i]);
            }
            if(getCampus(g, vertices[i]) == getWhoseTurn(g) + 3) {
                printf("You have a GO8 on %s\\0\n", vertices[i]);
            }
            i++;
        }
        printf("You have %d Publications\n", getPublications(g, getWhoseTurn(g)));
        printf("You have %d IP Patents\n", getIPs(g, getWhoseTurn(g)));
        printf("\n");
        
        printf("Students:\n");
        printf("You have %d THD Students\n", getStudents(g, getWhoseTurn(g), STUDENT_THD));
        printf("You have %d BPS Students\n", getStudents(g, getWhoseTurn(g), STUDENT_BPS));
        printf("You have %d BQN Students\n", getStudents(g, getWhoseTurn(g), STUDENT_BQN));
        printf("You have %d MJ Students\n", getStudents(g, getWhoseTurn(g), STUDENT_MJ));
        printf("You have %d MTV Students\n", getStudents(g, getWhoseTurn(g), STUDENT_MTV));
        printf("You have %d MMONEY Students\n", getStudents(g, getWhoseTurn(g), STUDENT_MMONEY));
        printf("\n");

        if(automation == FALSE) {
            a = getHumanAction();
        } else {
            a = getAIAction(g);
        }

        while(a.actionCode != PASS) {
            if(isLegalAction(g, a)) {
                if(a.actionCode == START_SPINOFF) {
                    if(rand() % 3 > 1) {
                        a.actionCode = OBTAIN_IP_PATENT;
                    } else {
                        a.actionCode = OBTAIN_PUBLICATION;
                    }
                }
                makeAction(g, a);
            } else {
                printf("Illegal Action");
            }
            printf("\n");
            printf("Player %d's turn\n", getWhoseTurn(g));

            printf("You have %d ARCs\n", getARCs(g, getWhoseTurn(g)));
            printf("You have %d Campuses\n", getCampuses(g, getWhoseTurn(g)));
            printf("You have %d GO8s\n", getGO8s(g, getWhoseTurn(g)));
            printf("You have %d Publications\n", getPublications(g, getWhoseTurn(g)));
            printf("You have %d IP Patents\n", getIPs(g, getWhoseTurn(g)));
            printf("\n");
            printf("Students:\n");
            printf("You have %d THD Students\n", getStudents(g, getWhoseTurn(g), STUDENT_THD));
            printf("You have %d BPS Students\n", getStudents(g, getWhoseTurn(g), STUDENT_BPS));
            printf("You have %d BQN Students\n", getStudents(g, getWhoseTurn(g), STUDENT_BQN));
            printf("You have %d MJ Students\n", getStudents(g, getWhoseTurn(g), STUDENT_MJ));
            printf("You have %d MTV Students\n", getStudents(g, getWhoseTurn(g), STUDENT_MTV));
            printf("You have %d MMONEY Students\n", getStudents(g, getWhoseTurn(g), STUDENT_MMONEY));
            printf("\n");

            if(automation == FALSE) {
                a = getHumanAction();
            } else {
                a = getAIAction(g);
            }

        }
        printf("Player 1 KPI points : %d\n", getKPIpoints(g, UNI_A));
        printf("Player 2 KPI points : %d\n", getKPIpoints(g, UNI_B));
        printf("Player 3 KPI points : %d\n", getKPIpoints(g, UNI_C));
    }
    printf("Winner: Player %d\n", getWinner(g));    
    disposeGame(g);
    return EXIT_SUCCESS;
}