INDEXMASTRBRINDEX !BOOT 3 '#.*BASIC
PAGE=&1900
*FX21
CLOSE#0:CHAIN "INDEX"
/// Masterbrain /// V1
Copyright Acornsoft 1982
Dd@:
(*FX200,3
27:23;10,32,0;0;0;
< I%=0 &3FF 4
FI%!&7C00=I%!&27B0:
PI=(300)
Z*RUN"MASTRBR"
[
d*FX200,3
n7:23;10,32,0;0;0;
xPD("Masterbrain"):Th@
r'"Masterbrain is a game of logical deduction and reasoning, and is also known as Bulls and Cows."'
"In this version of the game, you and the computer each think of a four-digitcode using any of the numbers 1 to 7 (Note: not 0, 8 or 9)."
"Each player then takes it in turn to try to guess the other's code, using information received from the opponent in response to previous attempts."
'"Clues:":*FX200,2
"When a player enters a guess of the opponent's code, the opponent must respond with a clue. This is made up of two numbers, the bulls and the cows."
8centre(&87+" Press the SPACE BAR to continue.",23)
=32:28,0,22,39,3::*FX15
"Bulls are scored when correct digits have been placed in the correct position of the code; cows are correct digits in incorrect positions. No digitin the attempt can contribute to both"
"the number of bulls and the number of cows. For example, assume the code to be guessed is 3627. If the opponent'sfirst guess is 7245, the clue which will be given in response should be 0"
ܤ"bulls (since none of the digits in the guess are in the right position) and 2 cows (the 7 and the 2 are part of the code but are in the wrong position)."
"Another guess of 3375 would score 1 bull (since the first 3 is in the rightposition) and 1 cow (again the 7 is in the wrong position - note that the second 3 scores no points)."
=32::*FX15
#"Following guesses could be:"
'" 3427 3 bulls 0 cows"
'" 3246 1 bull 2 cows"
'" 3672 2 bulls 2 cows"
"'" 3627 4 bulls 0 cows"
,0'"At this point the code has been broken."
6=32::*FX15
@"Running The Program:"
Jl"The computer will first ask whether youwant to play in colour or black and white. Press C or B."
T'"The playing sheet will now be shown. You should first think of the code you want the computer to try and guess and make a note of it. You can now enter your guess of the computer's code by"
^"pressing any four of the keys 1 to 7, followed by RETURN. You can correct your guess using the DELETE key at any time before you press RETURN."
h'"The computer will respond with the number of bulls (under the B column) and cows (under the C column), and makes its guess at your code."
r=32::*FX15
|"You should now check the computer's guess against the code you made a note of, and enter the number of bulls and cows. Take care to enter the right numbers."
'"If you cheat, the computer will find you out and declare itself the winner! Again, use the DELETE key to correct any errors before pressing RETURN."
c'"Play will then continue until both you and the computer correctly identify the codes."
l'"At any point when you are entering yourguess of the computer's code, you can press R for resign."
0"The computer will then reveal its code.";
=32::*FX15
"When both codes have been identified, press SPACE to get the current score. This will show the number of games the player has correctly identified the codes, the total number of guesses so"
W"far (Tries), and the average number of tries taken per code correctly guessed."
=32:
4PD(A$)I%=01:&9D81;&8D83;:(16-A$2)A$::
,centre(A$,vpos)(19-A$2),vpos);A$:
Masterbrain Masterbrain Copyright (C) Acornsoft 1982
/// Masterbrain /// V1
Copyright Acornsoft 1982
*FX200,2
2X M%3,N%3,C%0,B%0,L%9,U%24,G%40,R%40,O%0,W%9,MC%200,GOSUB%(4),IF%(10),HIMEM%(7):YJU
< *FX15
F
*FX4 1
Pu7:10,10);"Do you want colour(C)"'10)"or Black & White(B) ";:A%=:A%=A%&DF:A%>32A%,8:A%="C" A%="B"
ZA%="B"NNUQK UXWMWY
d(LN%=0:ON%=4::GOSUB%(0)=GOSUB%(0)+1
nY%=1:Z%=1:@%=2
x9I%=31-2:(HIMEM%(I%)),&8D,14)"Masterbrain"::'
&97:" ";34,112);&70
EI%=015:" "&97;&35;&87;18);&97;255;&87;36);&97;&6A:
c:A%=!M%
c:Q%=!M%
_I%=0:0,3)(HIMEM%(2))" You: B C"&97;255;(HIMEM%(6))"Computer: B C"19,4)255
,I%=I%+4:ON%=ON%+1:LN%,ON%);I%4:*FX15
! Y% a:GOSUB%(3)=GOSUB%(3)+1
! Z% b:GOSUB%(4)=GOSUB%(4)+1
/I%=48Y%l:"Too many attempts.":Y%=0:Z%=0
Y%=0 Z%=0
/6,23)"Press SPACE BAR to continue":=32
:''&8D;(HIMEM%(1))"Scores:"'&8D;(HIMEM%(1))"Scores:"'''" Games: Turns: Average:"''"Computer:-"12)GOSUB%(1)22)GOSUB%(4)32);
?GOSUB%(1)=0:"Infinite":(GOSUB%(4)/GOSUB%(1)*1000)/1000
o'"Opponent:-"11)GOSUB%(2) 21)GOSUB%(3);32);:GOSUB%(2)=0:"Infinite":(GOSUB%(3)/GOSUB%(1)*1000)/1000
46,20)"Press SPACE BAR to play again":=32:
YJU:21
"I%=01:P%=MC%
, [OPT0
6.find LDA #0: LDX #13
@$.loop STA C%,X:DEX:BPLloop:LDY#3
J9.again LDA M%,Y:CMP N%,Y:BNE nobull:INC B%:BPL return
T-.nobull TAX:INC L%,X:BEQ jump:BPL notcow:
^.jump INC C%
h/.notcow LDX N%,Y:DEC L%,X:BMI return:INC C%
r.return DEY:BPL again:RTS
|.LL7 SEC:LDX #3
/.LL9 LDA M%,X:ADC #0:CMP#8:BNELL8:LDA#1:SEC
!.LL8 STA M%,X:DEX:BPL LL9:RTS
.guess JSR LL7:LDX #3
5.LL14 LDA M%,X:CMP W%,X:BNE LL11:DEX:BPL LL14:RTS
.LL11 LDX #0
.LL12 LDY #0
.LL13 LDA G%,X:STA N%,Y:INX:INY:CPY #4:BNE LL13:TXA:PHA:JSR find:PLA:TAX:LDA C%:CMP R%-4,X:BNE guess:LDA B%:CMP R%-3,X:BNE guess:CPX O%:BNE LL12:RTS
]::6:
KQSYHI
'K%=03:M%?K%=(J%7)+1:J%=J%10::
f
c:!W%=!M%:?O%=I%:E%=0
l:"Thinking";
guess
!M%=!W%:l:
E%=E%+1:IF%(E%)=!M%:".";
&E%=10:l:
0 m
:$E%=0l:"You cheated, ";:Z%=0:
DF%=0
ND%=1E%
XK%=024:U%?K%=0:
b$J%=1E%:!M%=IF%(D%):!N%=IF%(J%)
l
find
v#U%?(?B%*5+?C%)=U%?(?B%?5+?C%)+1
:H%=0
K%=024
U%?K%<>0:H%=H%+1
:H%>F%:F%=H%:Q%=IF%(D%)
:l:
c
J%=:KQSYHI:
g
K%=03
.LN%+K%*2+21,ON%);(HIMEM%(H%15));H%15;
H%=H%/256::
r
l:"My number was:";
=H%=A%:OR%=ON%:PI%=LN%:LN%=-20:ON%=:g:ON%=OR%:LN%=PI%:
a
K%=0:
K%<4:LN%+K%*2+5,ON%);
*3J%=:J%="R":Y%=0:LN%+K%*2+4,ON%)&12:r:
4VJ%>48J%<56K%<4:M%?K%=J%-&30:LN%+K%*2+4,ON%);(HIMEM%(J%-&30));J%-&30;:K%=K%+1
>.K%>0J%=&7F:K%=K%-1:LN%+K%*2+5,ON%)" ";
HK%=4J%=13
R!N%=A%:find
\8LN%+14,ON%);&87;(?B%+&30);LN%+17,ON%)(?C%+&30)
f!C%<>&400:
p8Y%=0:l:Z%"...and you win":GOSUB%(2)=GOSUB%(2)+1:
z"About time too!":
b
H%=Q%:g
" ";
K%=0:V%=0:
UJ%=:J%>47J%<58K%<2LN%+32+K%*2,ON%);&87;J%-&30;9;:K%=K%+1:V%=J%-&30+V%*256
JK%>0J%=&7F K%=K%-1:V%=V%/256:LN%+K%*2+33,ON%)" "LN%+K%*2+33,ON%);
K%=2J%=13
R%!(I%-4)=V%
G%!(I%-4)=Q%
l
V%<>&400:f:m:Z%:
4Z%=0:Y%:"...So I win!":GOSUB%(1)=GOSUB%(1)+1:
+"Got it!":GOSUB%(1)=GOSUB%(1)+1:Y%=0:
l
0,21);39," ");0,21);:
NNUQK
$I%=07:HIMEM%(I%)=&87::
.
UXWMWY
8!I%=07:HIMEM%(I%)=I%+&80::
c'd'@'b' y'LLa'b'e'b'c'd'a'`PAGE=&0E00
OLD
RUN
BASIC
pqrsprpqrsq'pL' Ȣ ʆp']ppL'qppq$qPl`