mrPass.c - OpenLearning
/*
 *  Mr Pass.  Brain the size of a planet!
 *
 *  Proundly Created by Richard Buckland
 *  Share Freely Creative Commons SA-BY-NC 3.0.
 *
 *  Edited by Jesse Zhou 09/05/2015
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

#include "Game.h"
#include "mechanicalTurk.h"

static int CanSpinoff (int numMJ, int numMTV, int numMMONEY);

//takes input typedef Game, outputs typedef action
action decideAction (Game g) {
   //Find out which player I am and create an action
   int myPlayerNumber = getWhoseTurn (g);
   action nextAction;

   // find out what resources I have
   int numBPS = getStudents (g, myPlayerNumber, STUDENT_BPS);
   int numBQN = getStudents (g, myPlayerNumber, STUDENT_BQN);
   int numMJ = getStudents (g, myPlayerNumber, STUDENT_MJ);
   int numMTV = getStudents (g, myPlayerNumber, STUDENT_MTV);
   int numMMONEY = getStudents (g, myPlayerNumber, STUDENT_MMONEY);

   if (CanSpinoff (numMJ, numMTV, numMMONEY)) {
      nextAction.actionCode = START_SPINOFF;
   } else {
      nextAction.actionCode = PASS;
   }

   if (isLegalAction (nextAction)) {
      makeAction (nextAction);
   }

   return nextAction;
}

static int CanSpinoff (int numMJ, int numMTV, int numMMONEY) {
   int legalAction = FALSE;
   if ((numMJ >= 1) && (numMTV >= 1) && (numMMONEY >=1)) {
      legalAction = TRUE;
   }
   return legalAction;
}

Download file: mrPass.c (1.3 KB)

Comments

Chat