Random game
Random game
Random game
Nimx Nimx Nimx Nimx Nimx
Listing 1
0 READ R:​DIM C(R):​DIM B(R,​6):​DIM X(R):​FOR J=1 TO R:​READ E:​C(J)=E:​NEXT J:​DATA 3,​3,​4,​5
1 DIM Q$(1):​CLS:​SETCOLOR 1,​8,​14:​SETCOLOR 2,​8,​0:​SETCOLOR 4,​1,​8:​? "NIMX":​GOSUB 9:​IF RND(0)<0.5 THEN 3
2 F=0:​WHILE F=0:​? "Your Move:​ ";:​INPUT A,​N:​IF A>=1 AND A<=R:​IF N>=1 AND N<=C(A):​C(A)=C(A)-N:​GOSUB 9:​F=1:​ENDIF:​ENDIF:​WEND
3 GOSUB 7:​IF I=0:​? "You Win! Return to Replay";:​INPUT Q$:​RUN:​ELSE:​? "My Move:​ ";:​FOR J=1 TO R:​X(J)=C(J):​NEXT J:​A=0:​S=1
4 WHILE A<R AND S<>0:​C(A)=X(A):​A=A+1:​N=0:​WHILE C(A)>0 AND S<>0:​C(A)=C(A)-1:​N=N+1:​GOSUB 7:​WEND:​WEND
5 IF S<>0 THEN C(A)=X(A):​A=RAND(R)+1:​WHILE C(A)=0:​A=RAND(R)+1:​WEND:​N=RAND(C(A))+1:​C(A)=C(A)-N
6 ? A;",​";N:​GOSUB 9:​GOSUB 7:​IF I=0:​? "I Win! Return to Replay";:​INPUT Q$:​RUN:​ELSE:​GOTO 2
7 FOR V=1 TO R:​P=32:​W=C(V):​FOR D=1 TO 6:​IF W>=P:​B(V,​D)=1:​W=W-P:​ELSE:​B(V,​D)=0:​ENDIF:​P=P/2:​NEXT D:​NEXT V:​S=0:​T=0:​I=0
8 FOR D=1 TO 6:​FOR J=1 TO R:​T=T+B(J,​D):​NEXT J:​S=S+T-(2*INT(T/2)):​NEXT D:​FOR J=1 TO R:​I=I+C(J):​NEXT J:​RETURN
9 ?:​FOR V=1 TO R:​IF V<10:​? " ";:​ENDIF:​? ;V;:​? ;" ";:​J=C(V):​WHILE J>0:​? ;"";:​J=J-1:​WEND:​?:​NEXT V:​?:​RETURN	

This is non-commercial site, its content is based on Atari 8-bit home computer contents and references.
If you feel your rights are violated by showing/using any part of contents of your product represented on this page, please contact me immediatelly so I can remove it!