home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 213 / 213.d81 / t.gin < prev    next >
Text File  |  2022-08-26  |  9KB  |  308 lines

  1. u
  2.             G I N   1 2 8
  3.          by K & R Slaminko
  4.  
  5.    This program is for the C128 in 80
  6. column mode. That's not the way I
  7. intended to write it, but there it is.
  8. See my rant session at the bottom for
  9. more info.
  10.  
  11.    Gin is a simple, old, and very
  12. popular card game played with a
  13. standard deck. You have 10 cards in
  14. your hand, and if you can arrange
  15. those cards into two sets of 3 and one
  16. set of four, you have Gin and win the
  17. hand. Your opponent is, of course,
  18. trying to do the same thing.
  19.  
  20.    A 3 card 'set' consists of:
  21.     - 3 cards of the same rank or
  22.     - 3 consecutive cards of the same
  23.       suit (called a Run).
  24.  
  25.    The Ace may be considered high or
  26. low in a run, but wraparound is not
  27. permitted. Q-K-A and A-2-3 are legit
  28. but K-A-2 is not.
  29.  
  30.    A 4 card set is the same with an
  31. extra card: 4 of a kind or 4
  32. consecutive cards of like suit.
  33.  
  34.    You must achieve a hand with two
  35. sets of 3 and one set of 4. Other
  36. combinations (e.g. two runs of 5)
  37. don't count. A card may only be
  38. counted as part of one set, so if you
  39. hold 3-4-5 clubs and the other 3
  40. fives, you can consider this as either
  41. a set of 4 (the four 5's) or as two
  42. sets of 3 (the run and the other 3
  43. 5's).
  44.  
  45.    A dealer is randomly chosen, and
  46. alternates every hand. The dealer's
  47. opponent is dealt an extra, 11th card
  48. and begins play by discarding one
  49. card. The other player then has the
  50. choice of either picking up that card
  51. or taking one from the deck. Then he
  52. discards and the first player is faced
  53. with the same choice. Play alternates
  54. this way until someone gets Gin, or
  55. all cards in the deck are used (a
  56. tie). Scoring is simply a matter of
  57. tracking how many hands each player
  58. wins.
  59.  
  60.    In Gin 128, your hand will be
  61. displayed face up at the bottom of
  62. the screen. Your opponent (the evil
  63. Knees) will play from the top. The
  64. deck and discard piles are shown in
  65. the middle. The computer checks for
  66. Gin after each discard.
  67.  
  68.    You can choose to play with a 1351
  69. mouse in port 1, a joystick in port 2,
  70. or the keyboard. Once you make this
  71. choice, you're stuck using that
  72. interface forever (or at least until
  73. you restart the program). The mouse
  74. and joystick interface involve
  75. pointing and clicking, the keyboard
  76. controls use different keys to
  77. indicate your choices.
  78.  
  79.    Knees' cards may be displayed face
  80. down unless he has Gin, face down
  81. until one of you gets Gin, or face up.
  82. This last option was used for
  83. debugging the program but I decided to
  84. leave it in as a sort of learning
  85. tool. Of course it's cheating to peek
  86. at your opponent's cards this way, but
  87. who'll know?
  88.  
  89.    Your hand may be displayed sorted
  90. by suit, by rank with Aces low, or by
  91. rank with Aces high. Any time you're
  92. being prompted to pick up or discard,
  93. you can change the sort order by
  94. pressing S (keyboard) or clicking on
  95. the word 'Re-sort' (mouse/joystick).
  96.  
  97.    To pick up a card with the
  98. keyboard, press 0 for the top card in
  99. the discard pile or 1 for a card from
  100. the deck. Mouse/joystick users can
  101. click on the appropriate pile or,
  102. alternatively, on the words 'discard'
  103. or 'deck'. The card you pick up will
  104. be inserted into your hand according
  105. to your sort preference, and will be
  106. highlighted by a flashing asterisk.
  107.  
  108.    Discarding is accomplished by
  109. pressing a letter key (a-k) or by
  110. clicking on the unwanted card.
  111.  
  112.    At the conclusion of each hand, you
  113. may choose to play again by pressing Y
  114. or N or by clicking on 'Y' or 'N' in
  115. the prompt.
  116.  
  117.    As a 128 program, Gin 128 does not
  118. return to Loadstar.
  119.  
  120.    -------------------------------
  121.  
  122.               RON'S RANT
  123.  
  124.    This was an exceptionally
  125. frustrating project. I initially
  126. thought Gin would be a very simple
  127. program to write and had, in fact,
  128. proposed it as a group project to try
  129. to get more people interested in
  130. programming for Loadstar. It's just
  131. as well that I got very little
  132. response to my call, as it turned out
  133. [way] more difficult than anticipated.
  134.  
  135.    I'd written several strategy card
  136. games (Hearts, Pinochle, etc) for the
  137. defunct LS Quarterly for the 128, and
  138. since the strategy for Gin was much
  139. simpler, I figured Gin would be a
  140. snap. [Wrong-O!] But since I didn't
  141. realize that yet, I started writing
  142. it in 128 mode since most of the
  143. gruntwork (card design, display,
  144. loading of the custom font, mouse
  145. interface, etc) would be identical to
  146. my earlier work so I could just edit
  147. one of those old programs. The
  148. intent was to eventually port it over
  149. to 64 mode once the logic was
  150. finished. Incidently, if you should
  151. be brave enough to look at the source
  152. code, you'll see that I stuck to
  153. BASIC 2.0 commands rather than 7.0 so
  154. the translation would be easier.
  155.  
  156.    As expected, programming the
  157. strategy was pretty easy: discard the
  158. card least like the rest of the hand,
  159. pick up the discard if it improved
  160. the hand otherwise pick from the
  161. deck. No big deal. The problem was
  162. getting the computer to reliably
  163. recognize the sets in a hand. Oh
  164. sure, 3 eights, 3 threes, and 4 tens
  165. -- these are are pretty easy to spot.
  166. But what if you have overlapping sets?
  167. Consider this hand (currently holding
  168. an 11th card):
  169.  
  170. Clubs:    QKA234
  171. Diamonds: 4K
  172. Spades:   4K
  173. Hearts:   K
  174.  
  175. OK, you've got a run of 4 (A234
  176. clubs), a run of 3 (QKA of clubs -
  177. oops that uses the Ace again), 4
  178. kings, and 3 fours. Every card is
  179. part of a legitimate set, but 3 of
  180. them (the K,A, and 4 of clubs) are
  181. each part of 2 sets. This hand can
  182. be arranged to form gin as:
  183.  
  184.     Set of 4 kings
  185.     Run A23 of clubs
  186.     Set of 3 fours
  187.     Discard the Queen.
  188.  
  189. Trying to get the computer to
  190. recognize that possible arrangement
  191. and ignore all others was a real pain.
  192. Yes, Knees, it really is OK to toss
  193. that Queen even though it's part of a
  194. set.
  195.  
  196. Turns out there's a whole bunch of
  197. similar hands that may or may not be
  198. Gin, depending on how the cards are
  199. grouped. In some, every card is part
  200. of a group and there's even a set of
  201. four, but no matter what card you
  202. throw away, the rest won't add up to
  203. Gin. I couldn't have Knees just sit
  204. there paralyzed with indecision.
  205. Optimum grouping of the cards is one
  206. of those tasks that the human brain
  207. handles fairly easily (at least once
  208. you get used to it),  but it just
  209. doesn't translate well into computer
  210. code.
  211.  
  212.    So I wrote some code, played a few
  213. hands (with Knees' cards face up) and
  214. watched the mistakes pile up. Fiddled
  215. with the code so those mistakes
  216. wouldn't recur and played some more.
  217. Knees made more stupid plays. Fiddled
  218. some more. Corrected those misplays
  219. but some of the earlier ones came
  220. back. Grrrr. Went on this way for a
  221. while until everything seemed right.
  222. Figured if I could play 20 straight
  223. hands without an error I'd be good to
  224. go. First 19 were fine, then on hand
  225. #20 Knees claimed Gin when he didn't
  226. really have it. Sigh. Fixed that and
  227. started over. This time on hand #20 I
  228. had Gin but the stupid program
  229. wouldn't recognize it. Aaaarrgggghhh!
  230.  
  231. At this point I shoved the whole thing
  232. aside for a few weeks so I could calm
  233. down.  Finally came back to it, found
  234. the problem, and have now played 100+
  235. consecutive games without Knees making
  236. a gross error. Does this mean I've
  237. covered every eventuality? Probably
  238. not but I've had enough of this
  239. frustration.
  240.  
  241. I quit! I'm giving up on my intentions
  242. of converting this program to C64 zip
  243. BASIC. All the various patches to
  244. handle special situations have made
  245. the code too large & too complex for
  246. that to be a simple matter.  Besides,
  247. I'm tired of messing with it.  I
  248. program for the Commodore because it's
  249. fun -  much like solving logic
  250. problems or doing other puzzles.  This
  251. program is no longer fun and I want to
  252. move on to something else.
  253.  
  254. Having said all that, and even though
  255. I'm fairly confident that it's working
  256. properly, I'd like to invite you all
  257. to let me know of any problems with
  258. Gin 128. If the computer credits you
  259. or Knees with a Gin you don't have, or
  260. conversely refuses to recognize a
  261. legal Gin, make a note of the cards in
  262. question and email them to me at
  263.  
  264.          krslam@netscape.net
  265.  
  266. and maybe I can figure out a fix.
  267.  
  268.              End of Rant.
  269.  
  270.  RS & KS
  271.  
  272.  
  273.  [Dave's Confession]: Yes, it is true.
  274. Knees Calhoun has found the Holly
  275. Tower! Being geographically
  276. challenged, his only clue was an old
  277. packet of Holly Sugar he found under
  278. an old table leg. The packet said that
  279. the sugar was manufactured from sug