Hot and Cold
- Type
- Game
- Category
- Code-breaking logic game (Master Mind variant)
- Author
- Heidi Brumbaugh
- Published in
- Antic, November 1987 (Vol. 6, No. 7)
- Year
- 1987
- Language
- Atari BASIC
- Requirements
- Any Atari 8-bit, Atari BASIC, joystick in port 1
- Tags
- antic, mastermind, logic, puzzle, deduction, joystick, graphics-1, atari-basic
- Related
- Red, White and Blue, Black Box, Altirra BASIC, Altirra, Pegboard, Red Squares
About the program
The code-breaking game known as Cows and Bulls, and later sold as Master Mind, was already old when Antic junior editor Heidi Brumbaugh wrote Hot and Cold for the November 1987 issue. The magazine had printed Master Mind games before: an assembly-language version as the October 1983 Game of the Month and an ST version called Deduction in December 1986. This was its first in Atari BASIC. Brumbaugh had also written Red, White and Blue, the Game of the Month for July 1987.
GRAPHICS 1 only has a handful of colours, so instead of coloured pegs the computer hides a row of four symbols, chosen from six. Repeats are allowed, which makes it harder. You have ten turns to find the right symbols in the right order.
What you need
Any Atari 8-bit, Atari BASIC and a joystick. The listing here also runs under the Altirra BASIC replacement ROM that many emulators use; one variable has been renamed for that (see "Changes from the published listing").
Typing it in
It's a short program. Special characters: {inv}…{/inv} (Atari key) for the YES/NO/BUTTON prompts, and two {INS CHAR} codes in line 235 (ESC, then CTRL-INSERT, each time), which form part of the marker drawn under YES. The six symbols are character codes in the DATA of line 15000.
How to play
The board lists turns 1–10, with W and H columns and a symbol menu on the right.
- Move the stick left/right to highlight a symbol and press the button to place it. Do this four times.
- The game asks OKAY ??. Push right to move the cursor to NO, left for YES, and press the button. NO lets you redo the guess.
- The H (hot) column shows how many symbols are right and in the right place, and W (warm) shows how many are right but in the wrong place. The rest are "cold". You aren't told which ones are hot or warm.
Brumbaugh's example: if the code is + * ! > and you guess + + * #, you get 1 hot (the first +) and 1 warm (the *). The second + isn't counted again. She suggested two approaches: guess one symbol four times (####) to rule symbols in or out, or make a few random guesses early to collect clues. All your guesses stay on screen. Win and you get "good job!"; after ten misses the answer is shown. Press the button to play again.
How it works
- Scoring without double-counting (lines 2000–2110). Copy the answer into
D$. First pass: every exact match adds a hot and blanks that position in bothD$and the guess. Second pass: for each remaining guess symbol, look for it anywhere inD$; a hit adds a warm and blanks that copy, so one answer symbol can't count twice. That's the standard Master Mind rule, and the blanking is what makes it work. - Highlighting by inverse. In GRAPHICS 1 the top bits of a character pick its colour, so adding 128 to a symbol's code (lines 6010 and 10010) shows it in a different colour register. That's how the current menu choice lights up.
- A key click.
POKE 53279,3in line 6045 clicks the console speaker as the highlight moves. X=2^2andX=1^1(lines 165, 300, 3060, 6045) don't use their result. They seem to be there just to waste a little time, since exponentiation is slow in Atari BASIC.
Variations to try
- For a harder game, allow fewer turns by lowering the 10 in
TURN<10(line 440). The board has no room for more than ten. - Make it easier with no repeats: in line 120, pick again if the symbol is already in
S$.
Changes from the published listing
| Line | As published | Now | Why |
|---|---|---|---|
| 6030, 6040, 6060 | MOVE |
MOVX |
Altirra BASIC (used by many emulators) has a MOVE command, so it rejected the lines that use a variable named MOVE, and the game then stopped with error 5 at line 6010. The same-length name keeps memory use identical; behaviour on Atari BASIC is unchanged. |
Listing
10 REM HOT AND COLD
20 REM BY HEIDI BRUMBAUGH
30 REM (c)1987, ANTIC PUBLISHING
100 GOSUB 10000:REM INITIALIZE
120 FOR I=1 TO 4:X=INT(RND(0)*6)+1:S$(I)=CHR$(C(X)):NEXT I:TURN=1:REM NEW GAME
130 GOSUB 5000:REM DRAW BOARD
132 REM GAME LOOP
135 M=1:POKE 709,14:POKE 711,96
137 POSITION 14,8:? #6;"select":POSITION 14,10:? #6;M$
140 POKE 77,0:FOR PEG=1 TO 4
150 GOSUB 6000:REM GET GUESS FOR EACH PEG
160 POSITION PEG+2,(TURN*2):? #6;CHR$(C(M))
165 GUESS$(PEG)=CHR$(C(M)):X=2^2
170 NEXT PEG
172 GOSUB 1100:REM ERASE SELECT MENU
180 REM CONFIRM GUESS
190 POSITION 15,8:? #6;"OKAY":POSITION 16,10:? #6;"??"
200 POKE 711,14:POKE 710,157
210 POSITION 14,12:? #6;"{inv}yes{/inv}"
220 POSITION 18,12:? #6;"{inv}NO{/inv}"
230 POKE 710,157:POKE 711,14
235 POSITION 14,13:? #6;"{INS CHAR}{INS CHAR}{INS CHAR} "
240 IF STRIG(0)=0 THEN 400
250 POKE 77,0:IF STICK(0)<>7 THEN 240
260 POKE 710,14:POKE 711,157
265 POSITION 14,13:? #6;" {inv}__{/inv}"
270 POKE 77,0:IF STRIG(0)=0 THEN 300
280 IF STICK(0)<>11 THEN 270
290 GOTO 230
300 POSITION 3,(TURN*2):? #6;" ":GOSUB 1000:X=2^2:GOTO 135
400 GOSUB 1000:REM ERASE CONFIRM MSG.
410 GOSUB 2000:REM EVALUATE GUESS
420 POSITION 8,(TURN*2):? #6;WHITE;" ";BLACK
430 IF BLACK=4 THEN 600:REM CHECK FOR WIN
440 IF TURN<10 THEN TURN=TURN+1:GOTO 135:REM CHECK FOR LOSS
500 REM LOST
510 POSITION 14,2:? #6;"better"
520 POSITION 15,4:? #6;"luck"
530 POSITION 15,6:? #6;"next"
540 POSITION 15,8:? #6;"time"
545 POSITION 0,23:? #6;"the answer was ";S$
550 GOSUB 3000
560 POSITION 14,2:? #6;" "
570 POSITION 15,4:? #6;" "
580 POSITION 15,6:? #6;" "
590 POSITION 15,8:? #6;" "
592 POSITION 0,23:? #6;" "
595 GOTO 120
600 REM WON
605 POSITION 15,3:? #6;"good"
610 POSITION 15,5:? #6;"job!"
620 GOSUB 3000
630 POSITION 15,3:? #6;" "
640 POSITION 15,5:? #6;" "
650 GOTO 120
1000 POSITION 15,8:? #6;" "
1010 POSITION 16,10:? #6;" "
1020 POSITION 14,12:? #6;" "
1030 POSITION 14,13:? #6;" "
1040 RETURN
1100 POSITION 14,8:? #6;" ":POSITION 14,10:? #6;" "
1110 RETURN
2000 REM COUNT WHITES AND BLACKS
2010 WHITE=0:BLACK=0:D$=S$
2020 FOR I=1 TO 4
2030 IF D$(I,I)=GUESS$(I,I) THEN BLACK=BLACK+1:D$(I,I)=" ":GUESS$(I,I)=" "
2040 NEXT I
2050 FOR I=1 TO 4
2060 IF GUESS$(I,I)=" " THEN 2100
2070 FOR J=1 TO 4
2080 IF D$(J,J)=GUESS$(I,I) THEN WHITE=WHITE+1:D$(J,J)=" ":GOTO 2100
2090 NEXT J
2100 NEXT I
2110 RETURN
3000 REM PLAY AGAIN?
3010 POSITION 14,12:? #6;"{inv}BUTTON{/inv}"
3020 POSITION 16,14:? #6;"{inv}TO{/inv}":POSITION 15,16:? #6;"{inv}PLAY{/inv}"
3030 IF STRIG(0)=1 THEN 3030
3040 POKE 77,0:POSITION 14,12:? #6;" "
3050 POSITION 16,14:? #6;" ":POSITION 15,16:? #6;" "
3060 X=2^2:RETURN
5000 REM DRAW BOARD
5005 GRAPHICS 1+16
5007 POKE 708,30:POKE 712,148
5010 POSITION 2,0:? #6;"GUESS W H"
5030 FOR I=2 TO 20 STEP 2
5040 POSITION 0,I:? #6;INT(I/2)
5050 NEXT I
5060 FOR I=1 TO 11:POSITION 12,I*2-2:? #6;MASTER$(I,I):NEXT I
5100 RETURN
6000 REM SELECT PEG
6005 POKE 77,0:IF STRIG(0)=0 THEN 6005
6010 POSITION 13+M,10:? #6;CHR$(ASC(M$(M))+128)
6020 POKE 77,0:IF STRIG(0)=0 THEN 6500
6030 MOVX=STICK(0):IF MOVX<>7 AND MOVX<>11 THEN 6020
6040 IF MOVX=7 AND M=6 OR MOVX=11 AND M=1 THEN 6020:REM OUT OF RANGE
6045 POKE 53279,3:X=1^1
6050 POSITION 13+M,10:? #6;M$(M)
6060 IF MOVX=7 THEN M=M+1:GOTO 6010
6070 M=M-1:GOTO 6010
6500 POKE 77,0:IF STRIG(0)=0 THEN 6500
6510 RETURN
10000 DIM S$(4),C(6),M$(6),GUESS$(4),D$(4),MASTER$(11)
10010 FOR I=1 TO 6:READ X:C(I)=X:M$(I)=CHR$(X+128):NEXT I:MASTER$="!!!!!!!!!!!"
10100 RETURN
15000 DATA 4,10,11,3,1,28
Download
The original program from the Antic disk, to LOAD or ENTER instead of typing it: HOTCOLD.BAS.
Credits
- Program listing: Hot and Cold — program listing (Antic, November 1987 (Vol. 6, No. 7)) — Heidi Brumbaugh
- Picture: After the first guess: four < symbols, one of them hot. — Heidi Brumbaugh (program); screenshot by the site
- Antic magazine scan (OCR text layer), November 1987, pp. 29 and 32: Hot and Cold, by Heidi Brumbaugh — Heidi Brumbaugh; Internet Archive, 1987
- Antic Software Archive — November 1987 - Vol. 6 No. 7 disk: HOTCOLD.BAS — Heidi Brumbaugh, 1987
