PATIENCE V - PAIRS by Colin Gooch from ZX Computing Apr/May.1985 CN Gooch presents the fifth in his mind stretching series on popular card pastimes of Somerset. This is a Patience game in which you are required to collect pairs of cards of the same value, irrespective of suit, from a grid of five by three cards. To take a pair they must be touching, vertically, horizontally or diagonally. Each card on the screen is referenced by a letter and you input those letters to make a move. Full rules are given in the program. In this presentation I have not attempted to simulate a normal playing card. The display size restricts the card dimensions too much for a good representation. In any case as the suits in this game are not used I have opted for a large numerical display of each card. Program operation The pack of cards to use is held in a string P$ and cards are transferred to the hand in play on the screen, represented by H$. When you input a move the program checks to see that this is a valid move, removes the two cards from H$, adds two new cards from P$, clears the display and reprints the new hand. Illegal moves will not be allowed. Line to line 1020 Defines functions which work out the positions of [a] card. 1030 Sets CAPS SHIFT. 1040 Calls initialisation instruction and pack set up subroutines. 1050-1060 Sets up initial hand and screen display. 1070-1080 Control loop. 1100-1130 Prints out the reference letters and the hand of cards. The card printing loop runs from Z1 which is the position of the first deleted card. PSL is a slicing variable which keeps track of the card in the pack. 1140-1180 Prints out a card. The value of the card is added to 9100 to give a RESTORE DATA value. This gives five values which print out the card from N$. 1200-1370 This subroutine accepts your input and checks that it is legal. Line 1240 ensures that whatever card is entered first, the order is earliest card first. The check can then be made that the cards are either 6, 5, 4 or 1 places apart. 1380-1470 Sets up the pack and shuffles it. Each card is five elements long: Name, value (2), suit and colour. 1480 Continuity. 1480-1570 End game routine. 1580-1680 Instructions. 1690-2040 Sets up N$(x) which contains all of the graphics to set up the cards. 2200-2220 Sets up graphics. 2230-2400 Data for graphics. 9101-9113 Data to print cards. It is essential that these line numbers are used as the program calls them directly. 9990-9993 Save routine. Program must be saved to auto-start at 2200 or graphics will not form. Variables used A counting variable COL colour of card DIF relative position of cards to be moved M,N,P,Q loops PSL pack slicer RES flag set to indicate game end resignation X,Y location of card Z(x) card reference value, derived from Z$ A$ assembling pack B$ suit C$ card in play D$ temporary string H$ hand in play P$ shuffled pack Z$ input Memory Although the program is not exceptionally long it uses quite a lot of RAM as it shuffles the strings around and will not run on the 16K machine. -- Another Fine Product transcribed by: Jim Grimwood (jimg@globalnet.co.uk), Weardale, England --