Cat’s Game

Developer(s): William J. Pedersen
Date: 1985
Type: Program
Platform(s): TS 2068
Tags: Game

Cat’s Game is a party game for the TS2040 printer. You give a starting serial number and the number of copies, and for each copy the program scatters 100 cat faces, each built from twelve user-defined graphics, at random places on the screen so that most of them overlap. The sheet is printed with the question “How many complete cat faces can you find in this gang?” and its serial number. The program then finds every complete face itself, marks it on screen, shows “ANSWER: n Cats” and prints the answer key. After the last copy it draws a bar graph of how many cats each sheet had, and prints that as well.

The title screen reads “©1985 The WIDJUP Co. by William J. Pedersen”. Joan Kealy reviewed the game in May–June 1987. It needs a 2040 printer for its printed output, at about seven inches of paper per copy; without one the whole game still runs on screen.

Program Analysis

Program Structure

  • Lines 4971–4983 read twelve UDGs (a–l) from BIN DATA statements: a 4×3 character cat face.
  • Line 4985 asks for the serial range; 4987–4988 clear the screen and print 100 faces at random positions.
  • Line 4989 LPRINTs the question with a small face and COPYs the screen.
  • Lines 4990–4993 scan every position, 4994 records the count in N() and prints the answer key, and 5000–5040 draw the distribution graph.

Notable Techniques

  • Complete faces are found by XOR: the face is printed with OVER 1 at each position, and if all twelve cells then read back as a space through SCREEN$ (LEN SCREEN$ = 1), the face there was intact. A UDG or a partial overlap reads back as an empty string. The face is printed again with OVER 1 to restore the screen.
  • Found faces are marked with two solid blocks across the middle row, so the printed answer key shows which cats counted.
  • The graph alternates paper colours per column with PAPER k-2*INT (k/2)+5 and prints multi-digit counts vertically.
  • Line 4996 saves the program with LINE 4970 and has a disabled second copy and verify sequence after a REM.

Potential Issues

  • N() is dimensioned 1 to 32, so a sheet with no complete faces would stop the program with a subscript error at line 4994. With 100 faces on screen this is very unlikely.
  • The scan of all 580 positions is slow in BASIC, so each copy takes a minute or two.

This copy comes from an Oliger (JLO SAFE) disk. It was converted for tape (the disk save at line 4996 was changed to a tape SAVE) and tested in ZEsarUX.

Related Articles

Review of Cat’s Game by Kidjup Co. ($7.50), described as a party game and teaching tool for the Timex/Sinclair 1000.

Image Gallery

Source Code

 4970 REM PUSSYPUSS
 4971 LET Save=4996: DATA BIN 0,BIN 11,BIN 1,BIN 1,BIN 1,BIN 1,BIN 10000000,BIN 1000000
 4972 DATA BIN 0,BIN 0,BIN 10000000,BIN 1000000,BIN 100111,BIN 11000,BIN 10100000,BIN 1000000
 4973 DATA BIN 0,BIN 1,BIN 11,BIN 101,BIN 11001001,BIN 110001,BIN 1010,BIN 100
 4974 DATA BIN 0,BIN 10000000,BIN 0,BIN 0,BIN 0,BIN 0,BIN 10,BIN 100
 4975 DATA BIN 100000,BIN 10000,BIN 1000,BIN 100,BIN 10,BIN 10000001,BIN 1100010,BIN 11010
 4976 DATA BIN 10000000,BIN 10011100,BIN 10101010,BIN 10001000,BIN 10001000,BIN 0,BIN 10000011,BIN 1
 4977 DATA BIN 10,BIN 1110010,BIN 10101010,BIN 100010,BIN 100010, BIN 1,BIN 10000010,BIN 0
 4978 DATA BIN 1000,BIN 10000,BIN 100000,BIN 1000000,BIN 10000000,BIN 11,BIN 10001100,BIN 10110000
 4979 DATA BIN 110,BIN 101,BIN 1100,BIN 110010,BIN 11000001,BIN 0,BIN 0,BIN 0
 4980 DATA BIN 1,BIN 100000,BIN 11000,BIN 111,BIN 10000000,BIN 1110000,BIN 1000,BIN 111
 4981 DATA BIN 0,BIN 1001,BIN 110000,BIN 11000000,BIN 11,BIN 11100,BIN 100000,BIN 11000000
 4982 DATA BIN 11000000,BIN 1000000,BIN 1100000,BIN 10011000,BIN 110,BIN 1,BIN 0,BIN 0
 4983 FOR N=0 TO 95: READ A: POKE USR "a"+N,A: NEXT N
 4984 CLS : PRINT AT 5,4; FLASH 1;" STOP RECORDER "' FLASH 0'''"Party game. How many cats?"' INK 4;"*1985 The WIDJUP Co."'"by William J. Pedersen."' INK 1'" Attach 2040 printer and turn   it on before proceeding.  Make  sure you have enough paper.  It takes about 7 inches per copy." 
 4985 INPUT "Serial numbers start at? "; LINE W$: LET From=VAL W$: PRINT '"Serial numbers ";From;: INPUT "How many copies? "; LINE W$: LET To=VAL W$+From-1: PRINT " to ";To: PAUSE 360
 4986 REM  How many cats? 
 4987 DIM N(32): RANDOMIZE : INK 0: PAPER 7: BORDER 4: FOR j=From TO To: CLS 
 4988 FOR n=1 TO 100: LET Col=INT (29*RND): LET Row=INT (20*RND): PRINT AT Row,Col;"abcd";AT Row+1,Col;"efgh";AT Row+2,Col;"ijkl": NEXT n
 4989 LPRINT '"_______________________________"''" HOW MANY COMPLETE   abcd "'" CAT FACES CAN YOU   efgh"'" FIND IN THIS GANG?  ijkl #";j''': COPY 
 4990 LET Match=0: FOR k=0 TO 19: FOR n=0 TO 28: PRINT OVER 1;AT k,n;"abcd";AT k+1,n;"efgh";AT k+2,n;"ijkl"
 4991 FOR l=0 TO 2: FOR m=0 TO 3: IF NOT LEN SCREEN$ (k+l,n+m) THEN GO TO 4993
 4992 NEXT m: NEXT l: LET Match=Match+1: PRINT AT k+1,n+1;"::::"
 4993 PRINT OVER 1;AT k,n;"abcd";AT k+1,n;"efgh";AT k+2,n;"ijkl": NEXT n: NEXT k
 4994 LET N(Match)=N(Match)+1: PRINT AT 21,0; INVERSE 1;" #";j;" ANSWER: ";Match;" Cats  ": LPRINT "*1985 The WIDJUP Co."'"________________________________"'': COPY : PAUSE 60: NEXT j
 4995 LPRINT : GO SUB 5000: LPRINT '''"JOB COMPLETE #";From;" to #";To;''': STOP 
 4996 CLEAR : CLS : PRINT AT 5,0;"SAVING ""Cat's game""": SAVE "Cat's game" LINE 4970: REM PRINT '"Second copy": SAVE "Cat's game" LINE 4970: PRINT '"REWIND and CONT to VERIFY": STOP : VERIFY "": PRINT "Copy #1 O.K.": VERIFY "": PRINT "Copy #2 O.K.": STOP 
 5000 REM  GRAPH 
 5010 CLS : FOR l=26 TO 170 STEP 10: FOR m=2 TO 255 STEP 8: PLOT INK 2,m,l: DRAW INK 2,3,0: NEXT m: NEXT l: PRINT AT 7,0;" # of Cats  "'"Distribution"'To-From+1;" Samples";TAB 12; INK 2;AT 20,0;" 2 4 6 8 1 1 1 1 1 2 2 2 2 2 3 3         0 2 4 6 8 0 2 4 6 8 0 2"
 5020 FOR k=1 TO 32
 5024 LET W$=STR$ N(k)
 5025 PRINT PAPER k-2*INT (k/2)+5;AT 1,k-1;W$(1) AND N(k)
 5026 IF N(k)>9 THEN PRINT PAPER k-2*INT (k/2)+5;AT 2,k-1;W$(2)
 5027 IF N(k)>99 THEN PRINT PAPER k-2*INT (k/2)+5;AT 3,k-1;W$(3)
 5030 FOR j=2 TO 7: PLOT INK 1;8*k+j-9,16: DRAW INK 1;0,N(k): NEXT j
 5040 NEXT k: COPY : RETURN

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.