.title CRIB Notes .center64;CRIB .center64;a one-person cribbage game .center64;(two, if you count the VAX.) .b.lm 5.rm 65.no flags accept .hl 1 Author and obligatory disclaimer .nofill.nojust Dave Weigel Programmer/Analyst Diagonal Data Corporation 9700 Newton Avenue South Bloomington, MN, USA 55435 .just.fill.b2 This program is not a product of Diagonal Data Corporation, and is provided strictly AS IS. Sole responsibility for the contents of this program lies with the author. The program is provided to DECUS members free of charge, and is therefore not to be sold or reproduced for profit without the author's consent. .HL 1 Introduction CRIB is a single-player, vaguely intelligent, fun-for-the-whole-family version of the card game cribbage. CRIB stores statistics on each game played and, after a game is over, displays the player's "career" records. The game also stores records of how each played card works in a given situation, and learns from its mistakes. Because it uses VAX/VMS's SMG$ screen handling routines, it can be played on any VMS-supported terminal without code modification (and is even faster on a VT52 than a VT100). .hl 1 Installation CRIB requires three data files to run. One, CARD_HISTORY.DAT, contains the history of each card played in order for the computer to correctly choose a card to play the next time a similar situation turns up. The second, PLAY_HISTORY.DAT, contains one record for each game played. The third, GAMCRON., contains a list of times when it's okay to play. These files are to be assigned the logical GAMES:, and the first two will be created at run-time if they do not exist, provided that the logicals are assigned. All three files have been included in this distribution. A complete compilation and installation procedure might look like this: .test 9.lm +7.nofill.nojust.b $ basic crib $ create smgdef.mar .TITLE SMGDEF $SMGDEF GLOBAL .END $ macro smgdef $ link crib,smgdef $ run crib .lm-7.fill.just .hl 1 Technical notes .hl 2 How the game gets better When the computer needs to play a card, a strategy point value is given to each card remaining in the computer's hand, and the card with the highest point value is played. This point value has two components: basic cribbage strategy and the historical success of playing the card in a similar situation. These are the point values of the basic strategy (the pronoun "I" refers to the computer, and "you" is the player): .list.le;If this card makes four-of-a-kind, add 80 points. .le;If this card makes three-of-a-kind, add 10 * ((CardsAlreadyPlayed + MyCardsLeftToPlay) / YourCardsLeftToPlay+1) points. Add an additional 20 points if I still hold the fourth card of the same rank, or if this card is the fourth card played of this rank, or if the fourth card of this rank is the cut-card, or if playing the fourth card of the same rank would bring the count to over 31. .le;If this card makes two-of-a-kind, add 3 * ((CardsAlreadyPlayed + MyCardsLeftToPlay) / YourCardsLeftToPlay+1) points. Add an additional 12 points if I hold another card of this rank. Add an additional 10 points if a card of this rank has been played before the card I am about to pair, or if a card of this rank is the cut-card, or if playing another card of this rank would bring the count to over 31. .le;If this card makes a run of three or more, add 3 * (NumberOfCardsInRun) points. .le;If this card makes the count 5, subtract 5 points. .le;If this card makes the count 10, subtract 3 points. .le;If this card makes the count 15, add 15 points. .le;If this card makes the count 21, subtract 8 points. .le;If this card makes the count 30, add 3 points. .le;If this card makes the count 31, add 20 points. .le;If this card is an ace, subtract 3 points. .le;If this card is a two, subtract 1 point. .le;If this card is a five, subtract 5 points. .le;If this card is a jack, subtract 3 points. .le;If this card is a queen, add one point. .le;If this card is a king, add three points. .le;If this card is adjacent to another card in rank and playing to a run-of-three would count to 31, subtract 13 points. .le;If this card is adjacent to another card in rank and playing to a run-of-three would count to less than 31, subtract 8 points. .end list After a point value for a given card is calculated, the program checks the file GAMES:CARD_HISTORY.DAT for the historical success of this card when played after the previous two cards. For example, if these are the cards played since the last "GO": .b.nofill.nojust.lm+10 JH 5D 7H .b.fill.just.lm-10 and the cards remaining in the computer's hand are .b.nofill.nojust.lm+10 4D 7D 9S .b.fill.just.lm-10 the program will look up the combinations "574", "577", and "579" in CARD_HISTORY.DAT. If there have been fewer than two cards played since the last "GO", the program will substitute "X" for the card. For example, when leading a card after a "GO" with the cards in the above example, the program will look up "XX4", "XX7", and "XX9" in the file. Use the utility program CRIB_DUMP for a slightly formatted view of CARD_HISTORY.DAT. .b 2 When building the history, the same file lookup is done and the file updated depending on the success of the played card. "Success" is defined as "I got more points by playing my card than you got on your next card". .flag accept.hl 1 More to come... _...if not from me, then I hope from you. This game was originally written for two reasons: to help me play better cribbage, and because there really weren't any good VAX games around written in BASIC. Some of the corners were cut: the player doesn't have to count points, the player doesn't have to move a peg, cards aren't drawn to determine first deal, etc. I don't really intend on ever adding these - they don't add to developing a good cribbage strategy, and they're rather boring to do. .b;Some strategy elements I haven't done simply because I didn't get around to them. Your assignment is to do them and get them on the next SIG tape! Here's a list of some elements that might be added: .list.le;The game doesn't really have an end-game strategy - when I'm three points from winning, I should care more about keeping good pegging cards (aces, twos, fives) than keeping together the double-run. .le;Is keeping three cards of history enough? For most purposes it is, but then I lose the ability to trace long runs. If the last three cards are "AC", "4H", and "2D", I can't tell that I should play my three. .le;If I'm more than twenty points behind, I should know to take more risks. .le;The game doesn't try to trap the player into giving up more points than the player gets. For example, if I have three twos, I should lead a two in the hope that you will pair it, and I can triple it. .end list