home *** CD-ROM | disk | FTP | other *** search
- u
- G I N 1 2 8
- by K & R Slaminko
-
- This program is for the C128 in 80
- column mode. That's not the way I
- intended to write it, but there it is.
- See my rant session at the bottom for
- more info.
-
- Gin is a simple, old, and very
- popular card game played with a
- standard deck. You have 10 cards in
- your hand, and if you can arrange
- those cards into two sets of 3 and one
- set of four, you have Gin and win the
- hand. Your opponent is, of course,
- trying to do the same thing.
-
- A 3 card 'set' consists of:
- - 3 cards of the same rank or
- - 3 consecutive cards of the same
- suit (called a Run).
-
- The Ace may be considered high or
- low in a run, but wraparound is not
- permitted. Q-K-A and A-2-3 are legit
- but K-A-2 is not.
-
- A 4 card set is the same with an
- extra card: 4 of a kind or 4
- consecutive cards of like suit.
-
- You must achieve a hand with two
- sets of 3 and one set of 4. Other
- combinations (e.g. two runs of 5)
- don't count. A card may only be
- counted as part of one set, so if you
- hold 3-4-5 clubs and the other 3
- fives, you can consider this as either
- a set of 4 (the four 5's) or as two
- sets of 3 (the run and the other 3
- 5's).
-
- A dealer is randomly chosen, and
- alternates every hand. The dealer's
- opponent is dealt an extra, 11th card
- and begins play by discarding one
- card. The other player then has the
- choice of either picking up that card
- or taking one from the deck. Then he
- discards and the first player is faced
- with the same choice. Play alternates
- this way until someone gets Gin, or
- all cards in the deck are used (a
- tie). Scoring is simply a matter of
- tracking how many hands each player
- wins.
-
- In Gin 128, your hand will be
- displayed face up at the bottom of
- the screen. Your opponent (the evil
- Knees) will play from the top. The
- deck and discard piles are shown in
- the middle. The computer checks for
- Gin after each discard.
-
- You can choose to play with a 1351
- mouse in port 1, a joystick in port 2,
- or the keyboard. Once you make this
- choice, you're stuck using that
- interface forever (or at least until
- you restart the program). The mouse
- and joystick interface involve
- pointing and clicking, the keyboard
- controls use different keys to
- indicate your choices.
-
- Knees' cards may be displayed face
- down unless he has Gin, face down
- until one of you gets Gin, or face up.
- This last option was used for
- debugging the program but I decided to
- leave it in as a sort of learning
- tool. Of course it's cheating to peek
- at your opponent's cards this way, but
- who'll know?
-
- Your hand may be displayed sorted
- by suit, by rank with Aces low, or by
- rank with Aces high. Any time you're
- being prompted to pick up or discard,
- you can change the sort order by
- pressing S (keyboard) or clicking on
- the word 'Re-sort' (mouse/joystick).
-
- To pick up a card with the
- keyboard, press 0 for the top card in
- the discard pile or 1 for a card from
- the deck. Mouse/joystick users can
- click on the appropriate pile or,
- alternatively, on the words 'discard'
- or 'deck'. The card you pick up will
- be inserted into your hand according
- to your sort preference, and will be
- highlighted by a flashing asterisk.
-
- Discarding is accomplished by
- pressing a letter key (a-k) or by
- clicking on the unwanted card.
-
- At the conclusion of each hand, you
- may choose to play again by pressing Y
- or N or by clicking on 'Y' or 'N' in
- the prompt.
-
- As a 128 program, Gin 128 does not
- return to Loadstar.
-
- -------------------------------
-
- RON'S RANT
-
- This was an exceptionally
- frustrating project. I initially
- thought Gin would be a very simple
- program to write and had, in fact,
- proposed it as a group project to try
- to get more people interested in
- programming for Loadstar. It's just
- as well that I got very little
- response to my call, as it turned out
- [way] more difficult than anticipated.
-
- I'd written several strategy card
- games (Hearts, Pinochle, etc) for the
- defunct LS Quarterly for the 128, and
- since the strategy for Gin was much
- simpler, I figured Gin would be a
- snap. [Wrong-O!] But since I didn't
- realize that yet, I started writing
- it in 128 mode since most of the
- gruntwork (card design, display,
- loading of the custom font, mouse
- interface, etc) would be identical to
- my earlier work so I could just edit
- one of those old programs. The
- intent was to eventually port it over
- to 64 mode once the logic was
- finished. Incidently, if you should
- be brave enough to look at the source
- code, you'll see that I stuck to
- BASIC 2.0 commands rather than 7.0 so
- the translation would be easier.
-
- As expected, programming the
- strategy was pretty easy: discard the
- card least like the rest of the hand,
- pick up the discard if it improved
- the hand otherwise pick from the
- deck. No big deal. The problem was
- getting the computer to reliably
- recognize the sets in a hand. Oh
- sure, 3 eights, 3 threes, and 4 tens
- -- these are are pretty easy to spot.
- But what if you have overlapping sets?
- Consider this hand (currently holding
- an 11th card):
-
- Clubs: QKA234
- Diamonds: 4K
- Spades: 4K
- Hearts: K
-
- OK, you've got a run of 4 (A234
- clubs), a run of 3 (QKA of clubs -
- oops that uses the Ace again), 4
- kings, and 3 fours. Every card is
- part of a legitimate set, but 3 of
- them (the K,A, and 4 of clubs) are
- each part of 2 sets. This hand can
- be arranged to form gin as:
-
- Set of 4 kings
- Run A23 of clubs
- Set of 3 fours
- Discard the Queen.
-
- Trying to get the computer to
- recognize that possible arrangement
- and ignore all others was a real pain.
- Yes, Knees, it really is OK to toss
- that Queen even though it's part of a
- set.
-
- Turns out there's a whole bunch of
- similar hands that may or may not be
- Gin, depending on how the cards are
- grouped. In some, every card is part
- of a group and there's even a set of
- four, but no matter what card you
- throw away, the rest won't add up to
- Gin. I couldn't have Knees just sit
- there paralyzed with indecision.
- Optimum grouping of the cards is one
- of those tasks that the human brain
- handles fairly easily (at least once
- you get used to it), but it just
- doesn't translate well into computer
- code.
-
- So I wrote some code, played a few
- hands (with Knees' cards face up) and
- watched the mistakes pile up. Fiddled
- with the code so those mistakes
- wouldn't recur and played some more.
- Knees made more stupid plays. Fiddled
- some more. Corrected those misplays
- but some of the earlier ones came
- back. Grrrr. Went on this way for a
- while until everything seemed right.
- Figured if I could play 20 straight
- hands without an error I'd be good to
- go. First 19 were fine, then on hand
- #20 Knees claimed Gin when he didn't
- really have it. Sigh. Fixed that and
- started over. This time on hand #20 I
- had Gin but the stupid program
- wouldn't recognize it. Aaaarrgggghhh!
-
- At this point I shoved the whole thing
- aside for a few weeks so I could calm
- down. Finally came back to it, found
- the problem, and have now played 100+
- consecutive games without Knees making
- a gross error. Does this mean I've
- covered every eventuality? Probably
- not but I've had enough of this
- frustration.
-
- I quit! I'm giving up on my intentions
- of converting this program to C64 zip
- BASIC. All the various patches to
- handle special situations have made
- the code too large & too complex for
- that to be a simple matter. Besides,
- I'm tired of messing with it. I
- program for the Commodore because it's
- fun - much like solving logic
- problems or doing other puzzles. This
- program is no longer fun and I want to
- move on to something else.
-
- Having said all that, and even though
- I'm fairly confident that it's working
- properly, I'd like to invite you all
- to let me know of any problems with
- Gin 128. If the computer credits you
- or Knees with a Gin you don't have, or
- conversely refuses to recognize a
- legal Gin, make a note of the cards in
- question and email them to me at
-
- krslam@netscape.net
-
- and maybe I can figure out a fix.
-
- End of Rant.
-
- RS & KS
-
-
- [Dave's Confession]: Yes, it is true.
- Knees Calhoun has found the Holly
- Tower! Being geographically
- challenged, his only clue was an old
- packet of Holly Sugar he found under
- an old table leg. The packet said that
- the sugar was manufactured from sugar
- beets.
-
- So Knees put his nose in the air, and
- followed the sweet smell of the annual
- sugar beet migration. Unfortunately,
- Kit Carson had already driven the
- sugar beet herds to near extinction
- providing sugar packets for Harvey
- Houses along the Santa Fe Railroad.
-
- But by the time Knees discovered this
- ecologically pathetic fact, he was
- already in Garden City, KS. At the
- truck stop, he asked if anyone knew
- where Holly was, and some thoughtless
- person said, "Sure -- just 80 miles
- west on US 50."
-
- I discovered him moving his stuff
- into the Penthouse offices on the
- 213th floor. A ruckus broke out, and
- by the time we caught it and put it
- back in its cage, we had missed the
- deadline. Now you know the real reason
- this issue is late!
-
- DMM
-
-
-