- Start with 23 dots in DOTS.
- My first move is always 2.
- Store my move in MYGO.
- Display it.
- Subtract MYGO from DOTS.
- Check if DOTS is now ONE.
- Get your move in YRGO.
- Subtract YRGO from DOTS.
- Calculate my move by subtracting your move from 4.
- Go to step 3.
Note that this program does not validate
the other player's input ... so cheating is possible!
But it really won't help because the program cheats right back!
I will indicate "I Win!" by "1111" - the closest I can get to
four exclamation marks.
|
LDA #23
STA DOTS
LDA #2
LOOP: STA MYGO
OUT MYGO
LDA DOTS
SUB MYGO
STA DOTS
SUB #1
BEQ IWIN
INP YRGO
LDA DOTS
SUB YRGO
STA DOTS
LDA #4
SUB YRGO
JMP LOOP
IWIN: LDA #1111
STA WIN
OUT WIN
HLT
|