-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmrRetrainWorking.c
67 lines (63 loc) · 2.67 KB
/
mrRetrainWorking.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//Tries to retrain students so that it can start spin offs
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include "Game.h"
#include "mechanicalTurk.h"
action decideAction (Game g) {
int me = getWhoseTurn (g);
//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);
//retraining conditions
//last argument of getExchangeRate is useless
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 depending on resources
action nextAction;
if ((jobOwner * tvStar * moneyMaker) > 0) {
//create a spinoff
nextAction.actionCode = START_SPINOFF;
} else if (tvStar > costTv || jobOwner > costJob
|| moneyMaker > costMon || scientist >= costSci
|| engineer >= costEng) {
//retrain students so can start spin off
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
BQN -> BPS -> MTV -> MMONEY -> MJ
this ensures that BQN/BPS are retrained first*/
if (scientist >= costSci) {
nextAction.disciplineFrom = STUDENT_BQN;
} else if (engineer >= costEng) {
nextAction.disciplineFrom = STUDENT_BPS;
} else if (tvStar > costTv) {
nextAction.disciplineFrom = STUDENT_MTV;
} else if (moneyMaker > costMon) {
nextAction.disciplineFrom = STUDENT_MMONEY;
} else {
nextAction.disciplineFrom = STUDENT_MJ;
}
} else {
//no resources so end turn
nextAction.actionCode = PASS;
}
return nextAction;
}