data.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. /* $NetBSD: data.c,v 1.7 2004/01/01 15:59:09 jsm Exp $ */
  2. /*
  3. * Copyright (c) 1980, 1993
  4. * The Regents of the University of California. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. Neither the name of the University nor the names of its contributors
  15. * may be used to endorse or promote products derived from this software
  16. * without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  22. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  24. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. * SUCH DAMAGE.
  29. */
  30. #include <sys/cdefs.h>
  31. #ifndef lint
  32. #if 0
  33. static char sccsid[] = "@(#)data.c 8.1 (Berkeley) 5/31/93";
  34. #else
  35. __RCSID("$NetBSD: data.c,v 1.7 2004/01/01 15:59:09 jsm Exp $");
  36. #endif
  37. #endif /* not lint */
  38. #include "tutor.h"
  39. int maxmoves = 23;
  40. const char *const text0[] = {
  41. "To start the game, I roll a 3, and you roll a 1. This means",
  42. "that I get to start first. I move 8-5,6-5 since this makes a",
  43. "new point and helps to trap your back men on 1. You should be",
  44. "able to do a similar move with your roll.",
  45. 0
  46. };
  47. const char *const text1[] = {
  48. "Now you shall see a move using doubles. I just rolled double",
  49. "5's. I will move two men from position 13 to position 3. The",
  50. "notation for this is 13-8,13-8,8-3,8-3. You will also roll dou-",
  51. "bles, but you will be able to make a much stronger move.",
  52. 0
  53. };
  54. const char *const text2[] = {
  55. "Excellent! As you can see, you are beginning to develop a wall",
  56. "which is trapping my men on position 24. Also, moving your back",
  57. "men forward not only improves your board position safely, but it",
  58. "thwarts my effort to make a wall.",
  59. "",
  60. "My roll now is 5 6. Normally, I would use that roll to move from",
  61. "position 24 to position 13 (24-18-13), but your new point prevents",
  62. "that. Instead, I am forced to move from 13 to 2, where my man is",
  63. "open but cannot be hit.",
  64. 0
  65. };
  66. const char *const text3[] = {
  67. "As you can see, although you left a man open, it is a rela-",
  68. "tively safe move to an advantageous position, which might help",
  69. "you make a point later. Only two rolls (4 5 or 5 4) will allow",
  70. "me to hit you. With an unprecedented amount of luck, I happen",
  71. "to roll a 4 5 and hit you as just mentioned.",
  72. 0
  73. };
  74. const char *const text4[] = {
  75. "You're pretty lucky yourself, you know. I follow by rolling 2 3",
  76. "and moving 25-22,24-22, forming a new point.",
  77. 0
  78. };
  79. const char *const text5[] = {
  80. "Not a spectacular move, but a safe one. I follow by rolling 6 1.",
  81. "I decide to use this roll to move 22-16,16-15. It leaves me with",
  82. "one man still open, but the blot is farther back on the board, and",
  83. "would suffer less of a loss by being hit.",
  84. 0
  85. };
  86. const char *const text6[] = {
  87. "By moving your two men from 17 to 20, you lessen my chance of",
  88. "getting my man off the board. In fact, the odds are 5 to 4",
  89. "against me getting off. I roll with the odds and helplessly",
  90. "receive a 3 5.",
  91. 0
  92. };
  93. const char *const text7[] = {
  94. "Note that the blot on 7 cannot be hit unless I get off the bar",
  95. "and have a 1 or a 6 left over, and doing so will leave two of",
  96. "my men open. Also, the blot on 16 cannot be hit at all! With",
  97. "a sigh of frustration, I roll double 6's and remain immobile.",
  98. 0
  99. };
  100. const char *const text8[] = {
  101. "See, you did not get hit and, you got to 'cover up' your open men.",
  102. "Quite an accomplishment. Finally, I get off the bar by rolling",
  103. "6 2 and moving 25-23,23-17.",
  104. 0
  105. };
  106. const char *const text9[] = {
  107. "My venture off the bar did not last long. However, I got lucky",
  108. "and rolled double 1's, allowing me to move 25-24,24-23,15-14,15-14.",
  109. 0
  110. };
  111. const char *const text10[] = {
  112. "You are improving your position greatly and safely, and are well",
  113. "on the way to winning the game. I roll a 6 2 and squeak past",
  114. "your back man. Now the game becomes a race to the finish.",
  115. 0
  116. };
  117. const char *const text11[] = {
  118. "Now that it is merely a race, you are trying to get as many men",
  119. "as possible into the inner table, so you can start removing them.",
  120. "I roll a 3 4 and move my two men farthest back to position 11",
  121. "(15-11,14-11).",
  122. 0
  123. };
  124. const char *const text12[] = {
  125. "The race is still on, and you have seem to be doing all right.",
  126. "I roll 6 1 and move 14-8,13-12.",
  127. 0
  128. };
  129. const char *const text13[] = {
  130. "Notice that you get to remove men the instant you have all of",
  131. "them at your inner table, even if it is the middle of a turn.",
  132. "I roll 1 2 and move 13-11,12-11.",
  133. 0
  134. };
  135. const char *const text14[] = {
  136. "Although you could have removed a man, this move illustrates two",
  137. "points: 1) You never have to remove men, and 2) You should try",
  138. "to spread out your men on your inner table. Since you have one",
  139. "man on each position, you should be able to remove at least two",
  140. "men next turn. I roll 2 5 and move 8-6,11-6.",
  141. 0
  142. };
  143. const char *const text15[] = {
  144. "This time you were able to remove men. I roll 3 4 and move",
  145. "11-7,11-8. The race continues.",
  146. 0
  147. };
  148. const char *const text16[] = {
  149. "More holes are opening up in your inner table, but you are",
  150. "still very much ahead. If we were doubling, you would have",
  151. "doubled long ago. I roll 2 6 and move 8-6,11-5.",
  152. 0
  153. };
  154. const char *const text17[] = {
  155. "It pays to spread out your men. I roll 3 5 and move 7-4,8-3.",
  156. 0
  157. };
  158. const char *const text18[] = {
  159. "You can only remove some men, but you spread out more and",
  160. "more, in order to be able to remove men more efficiently.",
  161. "I roll double 3's, which help, but not that much. I move",
  162. "8-5,3-0,3-0,3-0.",
  163. 0
  164. };
  165. const char *const text19[] = {
  166. "I roll 1 4 and move 5-4,4-0.",
  167. 0
  168. };
  169. const char *const text20[] = {
  170. "You are now nicely spread out to win a game. I roll 5 6 and",
  171. "move 5-0,6-0.",
  172. 0
  173. };
  174. const char *const text21[] = {
  175. "Any minute now. Just a few short steps from victory. I roll",
  176. "2 4 and move 6-4,4-0.",
  177. 0
  178. };
  179. const char *const text22[] = {
  180. "It looks pretty hopeless for me, but I play on, rolling 1 3 and",
  181. "moving 4-3,3-0.",
  182. 0
  183. };
  184. const char *const text23[] = {
  185. "Congratulations! You just won a game of backgammon against the",
  186. "computer! You will now be able to play a game, but remember,",
  187. "when you start playing, that doubling will be enabled, which",
  188. "will add another factor to the game... Good luck!!",
  189. "",
  190. 0
  191. };
  192. const struct situatn test[] = {
  193. {
  194. {0, 2, 0, 0, 0, 0, -5, 0, -3, 0, 0, 0, 5, -5, 0, 0, 0, 3, 0,
  195. 5, 0, 0, 0, 0, -2, 0},
  196. 3, 1, {8, 6, 0, 0}, {5, 5, 0, 0}, 4, 2, {text0}
  197. },
  198. {
  199. {0, 2, 0, 0, 0, -2, -4, 0, -2, 0, 0, 0, 5, -5, 0, 0, 0, 2, 0,
  200. 4, 0, 2, 0, 0, -2, 0},
  201. 5, 5, {13, 13, 8, 8}, {8, 8, 3, 3}, 6, 6, {text1}
  202. },
  203. {
  204. {0, 0, 0, -2, 0, -2, -4, 2, -2, 0, 0, 0, 3, -3, 0, 0, 0, 2, 2,
  205. 4, 0, 2, 0, 0, -2, 0},
  206. 6, 5, {13, 8, 0, 0}, {8, 2, 0, 0}, 1, 2, {text2}
  207. },
  208. {
  209. {0, 0, -1, -2, 0, -2, -4, 2, -2, 0, 0, 0, 2, -2, 0, 1, 0, 2,
  210. 2, 4, 0, 2, 0, 0, -2, 0},
  211. 4, 5, {24, 20, 0, 0}, {20, 15, 0, 0}, 2, 5, {text3}
  212. },
  213. {
  214. {0, 0, 0, -2, 0, -2, -4, 3, -2, 0, 0, 0, 2, -2, 0, -1, 0, 2,
  215. 2, 4, 0, 2, 0, 0, -1, -1},
  216. 2, 3, {25, 24, 0, 0}, {22, 22, 0, 0}, 4, 1, {text4}
  217. },
  218. {
  219. {0, 0, 0, -2, 0, -2, -4, 2, -2, 0, 0, 0, 3, -2, 0, -1, 0, 2,
  220. 2, 4, 0, 2, -2, 0, 0, 0},
  221. 6, 1, {22, 16, 0, 0}, {16, 15, 0, 0}, 3, 3, {text5}
  222. },
  223. {
  224. {0, 0, 0, -2, 0, -2, -4, 2, -2, 0, 0, 0, 3, -2, 0, -2, 0, 0,
  225. 2, 2, 2, 2, 2, 0, 0, -1},
  226. 3, 5, {0, 0, 0, 0}, {0, 0, 0, 0}, 5, 4, {text6}
  227. },
  228. {
  229. {0, 0, 0, -2, 0, -2, -4, 1, -2, 0, 0, 0, 3, -2, 0, -2, 1, 0,
  230. 2, 2, 2, 2, 2, 0, 0, -1},
  231. 6, 6, {0, 0, 0, 0}, {0, 0, 0, 0}, 3, 6, {text7}
  232. },
  233. {
  234. {0, 0, 0, -2, 0, -2, -4, 0, -2, 0, 0, 0, 3, -2, 0, -2, 2, 0,
  235. 2, 2, 2, 2, 2, 0, 0, -1},
  236. 2, 6, {25, 23, 0, 0}, {23, 17, 0, 0}, 5, 1, {text8}
  237. },
  238. {
  239. {0, 0, 0, -2, 0, -2, -4, 0, -2, 0, 0, 0, 2, -2, 0, -2, 2, 0,
  240. 3, 2, 2, 2, 2, 0, 0, -1},
  241. 1, 1, {25, 24, 15, 15}, {24, 23, 14, 14}, 4, 6, {text9}
  242. },
  243. {
  244. {0, 0, 0, -2, 0, -2, -4, 0, -2, 0, 0, 0, 0, -2, -2, 0, 3, 0,
  245. 4, 2, 2, 2, 2, -1, 0, 0},
  246. 6, 2, {23, 17, 0, 0}, {17, 15, 0, 0}, 1, 3, {text10}
  247. },
  248. {
  249. {0, 0, 0, -2, 0, -2, -4, 0, -2, 0, 0, 0, 0, -2, -2, -1, 2, 0,
  250. 3, 4, 2, 2, 2, 0, 0, 0},
  251. 4, 3, {15, 14, 0, 0}, {11, 11, 0, 0}, 5, 3, {text11}
  252. },
  253. {
  254. {0, 0, 0, -2, 0, -2, -4, 0, -2, 0, 0, -2, 0, -2, -1, 0, 0, 0,
  255. 3, 5, 2, 3, 2, 0, 0, 0},
  256. 6, 1, {14, 13, 0, 0}, {8, 12, 0, 0}, 4, 4, {text12}
  257. },
  258. {
  259. {0, 0, 0, -2, 0, -2, -4, 0, -3, 0, 0, -2, -1, -1, 0, 0, 0, 0,
  260. 0, 5, 2, 2, 5, 0, 0, 0},
  261. 2, 1, {13, 12, 0, 0}, {11, 11, 0, 0}, 2, 1, {text13}
  262. },
  263. {
  264. {0, 0, 0, -2, 0, -2, -4, 0, -3, 0, 0, -4, 0, 0, 0, 0, 0, 0,
  265. 0, 5, 2, 2, 3, 1, 1, 0},
  266. 2, 5, {8, 11, 0, 0}, {6, 6, 0, 0}, 6, 3, {text14}
  267. },
  268. {
  269. {0, 0, 0, -2, 0, -2, -6, 0, -2, 0, 0, -3, 0, 0, 0, 0, 0, 0,
  270. 0, 4, 2, 2, 2, 1, 1, 0},
  271. 4, 3, {11, 11, 0, 0}, {7, 8, 0, 0}, 2, 5, {text15}
  272. },
  273. {
  274. {0, 0, 0, -2, 0, -2, -6, -1, -3, 0, 0, -1, 0, 0, 0, 0, 0, 0,
  275. 0, 4, 1, 2, 2, 0, 1, 0},
  276. 2, 6, {8, 11, 0, 0}, {6, 5, 0, 0}, 6, 1, {text16}
  277. },
  278. {
  279. {0, 0, 0, -2, 0, -3, -7, -1, -2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  280. 0, 3, 1, 2, 2, 0, 0, 0},
  281. 5, 3, {8, 7, 0, 0}, {3, 4, 0, 0}, 5, 2, {text17}
  282. },
  283. {
  284. {0, 0, 0, -3, -1, -3, -7, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  285. 0, 3, 0, 1, 2, 1, 0, 0},
  286. 3, 3, {8, 3, 3, 3}, {5, 0, 0, 0}, 1, 6, {text18}
  287. },
  288. {
  289. {0, 0, 0, 0, -1, -4, -7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  290. 1, 1, 1, 2, 1, 0, 0},
  291. 1, 4, {4, 5, 0, 0}, {0, 4, 0, 0}, 2, 3, {text19}
  292. },
  293. {
  294. {0, 0, 0, 0, -1, -3, -7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  295. 1, 1, 1, 1, 0, 0, 0},
  296. 5, 6, {6, 5, 0, 0}, {0, 0, 0, 0}, 1, 4, {text20}
  297. },
  298. {
  299. {0, 0, 0, 0, -1, -2, -6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  300. 1, 0, 1, 1, 0, 0, 0},
  301. 2, 4, {4, 6, 0, 0}, {0, 4, 0, 0}, 6, 2, {text21}
  302. },
  303. {
  304. {0, 0, 0, 0, -1, -2, -5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  305. 0, 0, 0, 1, 1, 0, 0},
  306. 3, 1, {4, 3, 0, 0}, {3, 0, 0, 0}, 4, 3, {text22}
  307. },
  308. {
  309. {0, 0, 0, 0, 0, -2, -5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  310. 0, 0, 0, 0, 0, 0, 0},
  311. 0, 0, {0, 0, 0, 0}, {0, 0, 0, 0}, 0, 0, {text23}
  312. }
  313. };