FOX
Game is designed for 1 or 2 players, trying to catch a target (a fox).
The speed is given, you may adjust direction of your next move.
The direction of the fox is random, as well as its starting position.
Game ends, when one of the player is nearer than 20 units.
You can set this value (line 28,29), as well as the iteration count of
the algorithm (line 3). By replacing
REM 1
to
GOTO 1
(line 60), you'll change the game to 1 player version.
Source code (746 B)
CLRT
IF D>0 GOTO 2
K=20
STATxy
A=70+50RANDOM
B=A(.6+RANDOM
Q=E2+900RANDOM
R=E2+700RANDOM
T=300
U=300
V=800
W=600
C=-K
DATA A,B
PRINT"SPEEDS
GOSUB 3
LABEL 1
CLRT
C=C+K
D=E9
F=D
X=360RANDOM
LABEL 2
θ=√((Q-T)2+(R-U)2
E=√((Q-V)2+(R-W)2
D=.5(D+θ-ABS (D-θ
F=.5(F+E-ABS (F-E
IF θ<=20 GOTO 6
IF E>20+ABS E9C GOTO 4
C=C-1
Q=Q+G
R=R+H
T=T+I
U=U+J
V=V+Σx
W=W+Σy
IF E>20 GOTO 2
PRINT"2.PLAYER
GOTO 7
LABEL 4
STATxy
DATA Q,R
PRINT"FOX -POS.
GOSUB 3
PRINT"FOX -DIRECT.
DATA X,0
GOSUB 3
PRINT"1.PL-DIST.
DATA θ,D
GOSUB 3
PRINT"1.PL-POS.
DATA T,U
GOSUB 3
PRINT"1.PL-DIRECT.
G=AK-1cos X
H=AK-1sin X
INPUT Y
I=BK-1cos Y
J=BK-1sin Y
REM 1
CLRT
PRINT"2.PL-DIST.
DATA E,F
GOSUB 3
PRINT"2.PL-POS.
DATA V,W
GOSUB 3
PRINT"2.PL-DIRECT.
INPUT Z
DATA cos Z,sin Z,BK-1
GOTO 1
LABEL 3
S=INT Σx+E-3INT Σy
STATxy
PRINT S
WAIT
CLRT
RETURN
LABEL 6
PRINT"1.PLAYER
LABEL 7
D=
PRINT"WELL DONE!