Home of the original IBM PC emulator for browsers.
By Jeff Parsons
This was one of my first attempts at “game logic” and probably not a very good attempt, given my limited programming experience at the time, as well as the memory constraints (8K of RAM).
1 REM--CHECKERS?--
2 REM-MEM.SIZE:8183-
3 T1=300:A=53448
5 FORC=1TO24:PRINT:NEXT:GOSUB10000:GOSUB20000
7 FORC=8184TO8191:READD:POKEC,D:NEXT:POKE11,248:POKE12,31
8 DATA32,0,253,141,255,31,96,0
10 FORC=A+640TOA+665:POKEC,32:NEXT:POKEA+640,63
11 M=USR(M):M=PEEK(8191)-48:IFM=9ANDG8=0THENG8=1:GOTO34
12 G8=1:IFM<1ORM>8THEN10
13 IFM=9ANDG9=1THENG9=0:GOTO34
14 IFM=9OR(M<>X1ANDG9=1)THEN10
15 POKEA+642,M+48:POKEA+643,44:X=M:M=USR(M):M=PEEK(8191)-48
16 IF(M<>Y1ANDG9=1)ORM<1ORM>8THEN10
17 POKEA+644,M+48
18 Y=M:M=USR(M):M=PEEK(8191)-48
19 IF(G9=1ANDABS(X-M)<>2)ORM<1ORM>8THEN10
20 POKEA+646,M+48:POKEA+647,44:X1=M:M=USR(M):M=PEEK(8191)-48
23 IFM<1ORM>8THEN10
25 POKEA+648,M+48:Y1=M:IFABS(X-X1)<>ABS(Y-Y1)THEN10
26 IFABS(X-X1)>2ORX>8ORY>8ORX1>8ORY1>8THEN10
27 IFP(X,Y)<1ORP(X1,Y1)<>0THEN10
28 IFP(X,Y)=1ANDY1<YTHEN10
29 IFABS(X-X1)=2ANDP((X+X1)/2,(Y+Y1)/2)>-1THEN10
30 P(X1,Y1)=P(X,Y):P(X,Y)=0:IFABS(X-X1)=2THENP((X+X1)/2,(Y+Y1)/2)=0
31 IFY1=8THENP(X1,Y1)=2
32 IFABS(X-X1)=2THENGOSUB20000:G9=1:GOTO10
33 GOSUB20000
34 FORC=A+640TOA+665:POKEC,32:NEXT
35 REM-MAIN PROGRAM-
230 G=-1:R=-99:FORY=1TO8:FORX=1TO8
231 IFP(X,Y)>-1THEN350
300 W=8:M=P(X,Y)
310 IFM=-1THENFORA1=-1TO1STEP2:B1=G:GOSUB650:NEXTA1
330 IFM=-2THENFORA1=-1TO1STEP2:FORB1=1TO-1STEP-2:GOSUB650:NEXTB1,A1
350 L6=0:L7=0:L8=0:L9=0:NEXTX,Y:GOTO1140
650 U=X+A1:V=Y+B1:IFU<1ORU>8ORV<1ORV>8THEN870
660 FORC1=-1TO1STEP2:FORD1=-1TO1STEP2
670 IFX+C1<1ORX+C1>8ORY+D1<1ORY+D1>8THEN700
673 IFX+C1*2<1ORX+C1*2>8ORY+D1*2<1ORY+D1*2>8THEN700
675 IFP(X+C1,Y+D1)>-1THEN700
680 IFP(X+C1*2,Y+D1*2)<>2ANDY+D1>YTHEN700
682 IFX-C1<1ORX-C1>8ORY-D1<1ORY-D1>8THEN685
683 IFP(X+C1,Y+D1)>0ANDP(X-C1,Y-D1)=0THENL9=1
685 IFP(X+C1*2,Y+D1*2)<1THEN700
690 Q=Q-4:GOTO740
700 NEXTD1,C1
740 IFP(U,V)=0THENGOSUB910:GOTO870
770 IFP(U,V)<0THEN870
790 U=U+A1:V=V+B1:IFU<1ORV<1ORU>8ORV>8THEN870
850 IFP(U,V)=0THENGOSUB910
870 RETURN
910 REM
920 IFABS(Y-V)=2THENQ=Q+4
930 IFL8=0ANDP(X,Y)=-1THENQ=Q+(2-Y/2)
1000 IFP(X,Y)=-2THENQ=Q-1
1030 IFP(X,Y)=-1THENFORC1=-1TO1STEP2:FORD1=-1TO-1:GOTO1033
1031 IFP(X,Y)=-2THENFORC1=-1TO1STEP2:FORD1=-1TO1STEP2:GOTO1033
1032 GOTO1081
1033 IFU+C1<1ORU+C1>8ORV+D1<1ORV+D1>8THEN1080
1034 IFU+C1*2<1ORU+C1*2>8ORV+D1*2<1ORV+D1*2>8THEN1040
1035 IFP(U+C1,V+D1)<0ANDP(U+C1*2,V+D1*2)>0THENQ=Q+4
1036 IFU-C1<1ORU-C1>8ORV-D1<1ORV-D1>8THEN1080
1037 IFP(U+C1,V+D1)>0ANDP(U-C1,V-D1)<>0ANDP(U+C1*2,V+D1*2)=0THENQ=Q+2
1040 IFU-C1<1ORU-C1>8ORV-D1<1ORV-D1>8THEN1080
1042 IFV+D1>VANDP(U+C1,V+D1)<2THEN1050
1045 IFP(U+C1,V+D1)>0AND(P(U-C1,V-D1)=0OR(X=U-C1ANDY=V-D1))THEN5000
1047 IFL9=1THENQ=Q+1:L7=1
1050 IFP(U+C1,V+D1)<>0ANDP(U-C1,V-D1)<>0ANDY<>8ANDP(X,Y)=-1THENQ=Q+1
1080 NEXTD1,C1
1081 IFL6=0THENQ=Q+4
1082 IFQ>RTHENR=Q:R1=X:R2=Y:R3=U:R4=V
1090 IFQ=RANDINT(RND(X)*10)+1<4THENR1=X:R2=Y:R3=U:R4=V
1100 Q=0:RETURN
1140 IFR=-99THEN1880
1230 R=-99:GOSUB2000
1240 IFR4=1THENP(R3,R4)=-2:GOTO1310
1250 P(R3,R4)=P(R1,R2)
1310 P(R1,R2)=0:IFABS(R1-R3)<>2THEN1420
1330 P((R1+R3)/2,(R2+R4)/2)=0
1340 X=R3:Y=R4:IFP(X,Y)=-1THENB1=-2:FORA1=-2TO2STEP4:GOSUB1370
1350 IFP(X,Y)=-2THENFORA1=-2TO2STEP4:FORB1=-2TO2STEP4:GOSUB1370:NEXTB1
1360 NEXTA1:IFR<>-99THENR=-99:GOTO1240
1365 GOTO1420
1370 U=X+A1:V=Y+B1:IFU<1ORU>8ORV<1ORV>8THEN1400
1380 IFP(U,V)=0ANDP(X+A1/2,Y+B1/2)>0THENGOSUB910
1400 RETURN
1420 FORT=1TO1400:NEXT:GOSUB20000:GOTO10
1880 PRINT:PRINT" I CONCEDE...":END
2000 REM-COMMENTS-
2010 POKEA+640,73:POKEA+642,65:POKEA+643,77
2015 IFABS(R1-R3)=2THEN2050
2017 POKEA+645,77:POKEA+646,79
2020 POKEA+647,86:POKEA+648,73:POKEA+649,78:POKEA+650,71:POKEA+651,46
2030 POKEA+652,46:POKEA+653,46:RETURN
2050 POKEA+645,74:POKEA+646,85:POKEA+647,77:POKEA+648,80:POKEA+649,73
2060 POKEA+650,78:POKEA+651,71:POKEA+652,46:POKEA+653,46:POKEA+654,46
2070 RETURN
4000 POKEB1,187:POKEB1+1,187:POKEB1+32,187:POKEB1+33,187:RETURN
5000 Q=Q-4:IFP(X,Y)=-2THENQ=Q-2
5002 L6=1
5003 IF(ABS(Y-V)=2ORABS(X-U)=2)ANDRND(X)*100<40THENQ=Q-1
5004 IFL9=1ANDL7=1THENQ=Q-1:L7=0
5005 GOTO1080
9999 END
10000 REM-CHESSBOARD-
10005 FORB=ATOA+15:POKEB,154:POKEB+544,155:NEXT
10010 FORB=B+32TOA+544STEP32:POKEB,156:POKEB-17,157:NEXT
10015 POKEA-1,165:POKEA+16,167:POKEA+560,168:POKEA+543,166
10017 GOTO10047:REM-THIS FOR ALTERNATE BOARD-
10020 FORB=A+33TOA+45STEP2:POKEB,143:POKEB+481,136:NEXT
10025 FORB=B+64TOA+512STEP64:POKEB,135:POKEB-47,128:NEXT
10040 FORB=A+66TOA+452STEP64:FORB1=BTOB+12STEP2:POKEB1,209:NEXTB1,B
10045 FORB=A+97TOA+481STEP64:FORB1=BTOB+12STEP2:POKEB1,207:NEXTB1,B
10047 REM-CHEC. INIT.--
10050 DIMP(8,8):FORX=1TO8:FORY=1TO3:IF(X+Y)/2=INT((X+Y)/2)THENP(X,Y)=1
10055 IF(X+Y+5)/2=INT((X+Y+5)/2)THENP(X,Y+5)=-1
10060 NEXTY,X:P(1,7)=-1
10065 X=57:FORB=A+62TOA+510STEP64:X=X-1:POKEB,X:NEXT
10070 FORB=A+576TOA+590STEP2:POKEB,X:X=X+1:NEXT
10075 RETURN
20000 REM--PIECES--
20005 Y=9:FORB=A+32TOA+480STEP64:X=0:Y=Y-1:FORB1=BTOB+14STEP2:X=X+1
20010 E3=168:M=P(X,Y):T=(X+Y)/2:IFM<0THENPOKEB1,88
20011 REM INSTRUCTIONS INVOLVING "T" ACCOUNT FOR FILLED BLOCKS
20012 IFT<>INT(T)THENGOSUB4000
20015 IFM>0THENPOKEB1,79
20017 IFT=INT(T)THENPOKEB1+1,32:POKEB1+32,32
20020 IFABS(M)=2THENE3=107
20040 IFM=0ANDT=INT(T)THENPOKEB1,32:POKEB1+33,32:GOTO20100
20050 IFT<>INT(T)THEN20100
20099 POKEB1+33,E3
20100 NEXTB1,B:RETURN