CRIB a one-person cribbage game (two, if you count the VAX.) 1 AUTHOR AND DISCLAIMER Dave Weigel Programmer/Analyst Diagonal Data Corporation 9700 Newton Avenue South Bloomington, MN, USA 55435 (I welcome any and all helpful hints to improve the play of the game and its strategy!) 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. 2 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. 3 INSTALLATION CRIB requires two data files to run. One, CARDHISTORY.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 other, PLAYHISTORY.DAT, contains one record for each game played. These files are to be assigned the logical GAME:, and will be created at run-time if they do not exist, provided that the logicals are assigned. A complete compilation and installation procedure might look like this: $ basic crib $ create smgdef.mar CRIB Page 2 .TITLE SMGDEF $SMGDEF GLOBAL .END $ macro smgdef $ link crib,smgdef $ run crib 4 TECHNICAL NOTES 4.1 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 a check on the situation's history. These are the point values of the basic strategy (the pronoun "I" refers to the computer, and "you" is the player): 1. If this card makes four-of-a-kind, add 80 points. 2. 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. 3. 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. 4. If this card makes a run of three or more, add 3 * (NumberOfCardsInRun) points. 5. If this card makes the count 5, subtract 5 points. 6. If this card makes the count 10, subtract 3 points. 7. If this card makes the count 15, add 15 points. 8. If this card makes the count 21, subtract 8 points. 9. If this card makes the count 30, add 3 points. CRIB Page 3 10. If this card makes the count 31, add 20 points. 11. If this card is an ace, subtract 3 points. 12. If this card is a two, subtract 1 point. 13. If this card is a five, subtract 5 points. 14. If this card is a jack, subtract 3 points. 15. If this card is a queen, add one point. 16. If this card is a king, add three points. 17. If this card is adjacent to another card in rank and playing to a run-of-three would count to 31, subtract 13 points. 18. 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.