Advertisement
Guest User

Untitled

a guest
May 6th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.11 KB | None | 0 0
  1.  
  2. /*
  3. * Game.h
  4. * 1917 v1.07
  5. * edit log -
  6. * 1.07 badly-drawn map region and dice values comment
  7. * 1.06 expanded comments on newGame(), explain regionID
  8. * 1.05 expanded the comments explaining isLegalAction()
  9. * 1.04 expanded path description, starting direction
  10. * 1.03 edited comment for getmostpubs() 30-apr-14
  11. * 1.02 abstract ADT version of Game
  12. * 1.00 concrete game type version
  13. * Do not alter this file
  14. *
  15. * Created by Richard Buckland on 20/04/14.
  16. * Licensed under Creative Commons SA-BY-NC 3.0.
  17. *
  18. */
  19.  
  20. #define NUM_UNIS 3
  21.  
  22. // player ID of each university
  23. #define NO_ONE 0
  24. #define UNI_A 1
  25. #define UNI_B 2
  26. #define UNI_C 3
  27.  
  28. // contents of an ARC
  29. #define VACANT_ARC 0
  30. #define ARC_A 1
  31. #define ARC_B 2
  32. #define ARC_C 3
  33.  
  34. // contents of a VERTEX
  35. #define VACANT_VERTEX 0
  36. #define CAMPUS_A 1
  37. #define CAMPUS_B 2
  38. #define CAMPUS_C 3
  39. #define GO8_A 4
  40. #define GO8_B 5
  41. #define GO8_C 6
  42.  
  43. // action codes
  44. #define PASS 0
  45. #define BUILD_CAMPUS 1
  46. #define BUILD_GO8 2
  47. #define OBTAIN_ARC 3
  48. #define START_SPINOFF 4
  49. #define OBTAIN_PUBLICATION 5
  50. #define OBTAIN_IP_PATENT 6
  51. #define RETRAIN_STUDENTS 7
  52.  
  53. // disciplines
  54. #define STUDENT_THD 0
  55. #define STUDENT_BPS 1
  56. #define STUDENT_BQN 2
  57. #define STUDENT_MJ 3
  58. #define STUDENT_MTV 4
  59. #define STUDENT_MMONEY 5
  60.  
  61. #define NUM_REGIONS 19
  62. #define PATH_LIMIT 150
  63.  
  64. #define TRUE 1
  65. #define FALSE 0
  66.  
  67. typedef struct _game * Game;
  68.  
  69. // your team designs this type not us
  70. // store in this struct all the things you might want to know about
  71. // the game so you can write the interface functions in this header
  72. // eg you might want to store the current turn number (so i've put
  73. // it in for you as an example but take it out if you don't want it)
  74.  
  75. // in your Game.c include the details of the data
  76. // you want to store in the _game struct eg
  77.  
  78. // typedef struct _game {
  79. // int currentTurn;
  80. // ... more stuff in here
  81. // } game;
  82.  
  83. // a path is a sequence of L=left R=right B=back steps
  84. // starting from the initial campus of player 1 / A at the top
  85. // of the map facing inwards represented as a string of length
  86. // PATH_LIMIT or less (including the terminating 0).
  87. // a path can specify a vertex (the vertex at the end of the path)
  88. // and a path can specify an ARC (the last ARC in the path)
  89. // it is fine and legal for a path to not be the shortest path
  90. // to the destination, it can even contain loops if you like.
  91. // The length of a path (including the terminating 0) must never
  92. // exceed PATH_LIMIT. Every edge in the path must lie on the
  93. // island, paths cannot include edges which are in the sea.
  94. typedef char path[PATH_LIMIT];
  95.  
  96. // actions are what the player AI returns. They say the one thing
  97. // the AI wants to do next. In the playGame logic you'll ask
  98. // a player for their next action, then you'll check it is a legal
  99. // action (using isLegalAction()), then you'll perform that action
  100. // for them (using makeAction()), then you'll ask the same player
  101. // for another action and repeat this over and over again until they
  102. // return PASS at which time you'll throw the dice (using
  103. // throwDice()) and advance the game to the next player. And repeat.
  104. typedef struct _action {
  105. int actionCode; // see #defines above
  106. path destination; // if the action operates on a vertex or ARC this
  107. // specifies *which* vertex or path. unused
  108. // otherwise
  109. int disciplineFrom; // used for the retrain students action
  110. int disciplineTo; // used for the retrain students action
  111. } action;
  112.  
  113. /* **** Functions which change the game aka SETTERS **** */
  114. // make a new game, given the disciplines produced by each
  115. // region, and the value on the dice discs in each region.
  116. // note: each array must be NUM_REGIONS long
  117. // eg if you are using my sample game struct above this function
  118. // would need to set the field currentTurn to -1. (because the turn
  119. // number is -1 at the start of the game)
  120. // the ordering of the regions is column by column left to right,
  121. // going from the top of each column to the bottom before moving
  122. // to the next column to the right.
  123. //
  124. // so to create the default game as shown on the badly drawn map:
  125. //
  126. /*
  127. #define DEFAULT_DISCIPLINES {STUDENT_BQN, STUDENT_MMONEY, STUDENT_MJ, \
  128. STUDENT_MMONEY, STUDENT_MJ, STUDENT_BPS, STUDENT_MTV, \
  129. STUDENT_MTV, STUDENT_BPS,STUDENT_MTV, STUDENT_BQN, \
  130. STUDENT_MJ, STUDENT_BQN, STUDENT_THD, STUDENT_MJ, \
  131. STUDENT_MMONEY, STUDENT_MTV, STUDENT_BQN, STUDENT_BPS}
  132. #define DEFAULT_DICE {9,10,8,12,6,5,3,11,3,11,4,6,4,7,9,2,8,10,5}
  133. */
  134. //
  135. // int disciplines[] = DEFAULT_DISCIPLINES;
  136. // int dice[] = DEFAULT_DICE;
  137. // Game g = newGame (disciplines, dice);
  138. Game newGame (int discipline[], int dice[]);
  139.  
  140. // free all the memory malloced for the game
  141. void disposeGame (Game g);
  142.  
  143. // make the specified action for the current player and update the
  144. // game state accordingly.
  145. // The function may assume that the action requested is legal.
  146. // START_SPINOFF is not a legal action here
  147. void makeAction (Game g, action a);
  148.  
  149. // advance the game to the next turn,
  150. // assuming that the dice has just been rolled and produced diceScore
  151. // the game starts in turn -1 (we call this state "Terra Nullis") and
  152. // moves to turn 0 as soon as the first dice is thrown.
  153. void throwDice (Game g, int diceScore);
  154.  
  155. /* **** Functions which GET data about the game aka GETTERS **** */
  156.  
  157. // what type of students are produced by the specified region?
  158. // regionID is the index of the region in the newGame arrays (above)
  159. // see discipline codes above
  160. int getDiscipline (Game g, int regionID);
  161.  
  162. // what dice value produces students in the specified region?
  163. // 2..12
  164. int getDiceValue (Game g, int regionID);
  165.  
  166. // which university currently has the prestige award for the most ARCs?
  167. // this is NO_ONE until the first arc is purchased after the game
  168. // has started.
  169. int getMostARCs (Game g);
  170.  
  171. // which university currently has the prestige award for the most pubs?
  172. // this is NO_ONE until the first publication is made.
  173. int getMostPublications (Game g);
  174.  
  175. // return the current turn number of the game -1,0,1, ..
  176. int getTurnNumber (Game g);
  177.  
  178. // return the player id of the player whose turn it is
  179. // the result of this function is NO_ONE during Terra Nullis
  180. int getWhoseTurn (Game g);
  181.  
  182. // return the contents of the given vertex (ie campus code or
  183. // VACANT_VERTEX)
  184. int getCampus(Game g, path pathToVertex);
  185.  
  186. // the contents of the given edge (ie ARC code or vacent ARC)
  187. int getARC(Game g, path pathToEdge);
  188.  
  189. // returns TRUE if it is legal for the current
  190. // player to make the specified action, FALSE otherwise.
  191. //
  192. // "legal" means everything is legal:
  193. // * that the action code is a valid action code which is legal to
  194. // be made at this time
  195. // * that any path is well formed and legal ie consisting only of
  196. // the legal direction characters and of a legal length,
  197. // and which does not leave the island into the sea at any stage.
  198. // * that disciplines mentioned in any retraining actions are valid
  199. // discipline numbers, and that the university has sufficient
  200. // students of the correct type to perform the retraining
  201. //
  202. // eg when placing a campus consider such things as:
  203. // * is the path a well formed legal path
  204. // * does it lead to a vacent vertex?
  205. // * under the rules of the game are they allowed to place a
  206. // campus at that vertex? (eg is it adjacent to one of their ARCs?)
  207. // * does the player have the 4 specific students required to pay for
  208. // that campus?
  209. // It is not legal to make any action during Terra Nullis ie
  210. // before the game has started.
  211. // It is not legal for a player to make the moves OBTAIN_PUBLICATION
  212. // or OBTAIN_IP_PATENT (they can make the move START_SPINOFF)
  213. // you can assume that any pths passed in are NULL terminated strings.
  214. int isLegalAction (Game g, action a);
  215.  
  216. // --- get data about a specified player ---
  217.  
  218. // return the number of KPI points the specified player currently has
  219. int getKPIpoints (Game g, int player);
  220.  
  221. // return the number of ARC grants the specified player currently has
  222. int getARCs (Game g, int player);
  223.  
  224. // return the number of GO8 campuses the specified player currently has
  225. int getGO8s (Game g, int player);
  226.  
  227. // return the number of normal Campuses the specified player currently has
  228. int getCampuses (Game g, int player);
  229.  
  230. // return the number of IP Patents the specified player currently has
  231. int getIPs (Game g, int player);
  232.  
  233. // return the number of Publications the specified player currently has
  234. int getPublications (Game g, int player);
  235.  
  236. // return the number of students of the specified discipline type
  237. // the specified player currently has
  238. int getStudents (Game g, int player, int discipline);
  239.  
  240. // return how many students of discipline type disciplineFrom
  241. // the specified player would need to retrain in order to get one
  242. // student of discipline type disciplineTo. This will depend
  243. // on what retraining centers, if any, they have a campus at.
  244. int getExchangeRate (Game g, int player,
  245. int disciplineFrom, int disciplineTo);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement