I thought I'd go back through some of my old projects and improve the code a bit. Starting with Croquet, here's the current code, and I'm curious to hear what people think about it.
Code:
[edit]
Only found one optimization so far.....
Code:
Code:
::DCS6
:7916C20B9905A482A041A460989081288245849A89249225A42DC81DD0037FFE
:AxesOff
:GridOff
:PlotsOff
:FnOff
:Degree
:{10+27.5{i},16+27.5{i},31+13.5{i},47+27.5{i},63+13.5{i},78+27.5{i},84+27.5{i},91+28{i},84+27.5{i},78+27.5{i},63+42.5{i},47+27.5{i},31+42.5{i},16+27.5{i},10+27.5{i},3+27{i}→{L1}
:seq(1-not(fPart(I/8)),I,1,16→{L2}
:seq(4,I,1,6
:Ans+27{i}→{L3}
:DelVar {L4}6→dim({L4}
:{L4}→{L5}
:{L5}→{L6}
:0→Xmin
:0→Ymin
:1→ΔX
:1→ΔY
:ClrDraw
:Horizontal(53
:Horizontal(48
:Vertical 59
:Text({-}1,1,16,"CROQUET 83+
:Text(11,64,"CROQUET
:For(I,0,1
:Text(12+31I,0,sub(" BLUE: RED: PRPL: YLLW: GRN: ORNG: ",23I+1,23
:22I
:Text(21+Ans,64,sub("CODED BY:GFX BY:",1+9I,9-2I
:Text(28+Ans,60,"THOMAS
:Text(35+Ans,60,"DICKERSO
:Text(35+Ans,91,"N
:For(X,5,41,18
:For(Y,10,41,31
:Line(X,Y-6I,X+12,Y-6I
:12I
:Line(X+Ans,Y,X+Ans,Y-6
:End
:End
:End
:StorePic 1
:For(X,6,42,18
:For(Y,21,52,31
:Text(Y,X,"PLR
:End
:End
:RecallPic 1
:DelVar IRepeat K=21
:getKey→K
:If K=45
:DelVar ZGoto N
:round(18+54fPart(I/3),0→X
:round(41-31iPart(I/3),0→Y
:Line(X,Y,X,Y-6
:X-14
:Line(Ans,Y,Ans,Y-6
:If 1=abs(K-25
:Then
:Line(X,Y,X,Y-6,0
:Line(Ans,Y,Ans,Y-6,0
:I+(K=26 and I≠5)-(K=24 and I→I
:End
:If 9=abs(2K-59
:Then
:{L6}(I+1
:Ans-(K=25 and Ans+1)+(K=34 and Ans≠9→{L6}(I+1
:If Ans<1
:Then
:sub("{-}{-}{-}PLR",3Ans+4,3
:Else
:"AI"+sub("123456789",Ans,1
:End
:Text(62-Y,X-12,Ans
:RecallPic 1
:End
:End
:ClrDraw
:Line(47,26,47,29
:Horizontal(54
:For(I,0,1
:Text(1,2+35I,sub("TURN:PWR: ",5I+1,5
:56+4I
:Line(51,Ans,92,Ans
:Line(22,46,1+21I,46+7I
:92-41I
:Line(Ans,56,Ans,60
:Horizontal(62I
:Vertical 94I
:13I
:Line(80,14,80+Ans,1+Ans
:Pt-On(3+88I,27+I
:10+74I
:Line(Ans,26,Ans,29
:16+62I
:Line(Ans,26,Ans,29
:31+32I
:Line(Ans,12,Ans,15
:Line(Ans,41,Ans,44
:End
:StorePic 1
:"BLUERED PRPLYLLWGRN ORNG→Str1
:DelVar TDelVar HWhile 1
:DelVar P
:If H=0
:Then
:Repeat 0≤{L6}(T
:T+(T≠6)-5(T=6→T
:End
:Else
:H-1→H
:End
:Text(1,20,sub(Str1,4T-3,4),"
:T→I
:Repeat I=T
:I+(I≠6)-5(I=6→I
:If 0≤{L6}(I
:Then
:round(imag({L3}(I)),0→Y
:round(real({L3}(I)),0→X
:Pt-Change(X,Y
:62-Y
:Text((Ans)(Ans≤57)+(Ans-6)(Ans>57),(X+1)(X≤90)+(X-4)(X>90),sub(Str1,4I-3,1
:If iPart(2fPart({L5}(T)/(2^I
:Text(9,2+4I-4-4(I>T),sub(Str1,4I-3,1
:End
:End
:RecallPic 1
:1+{L4}(T→Z
:real({L1}(Z→A
:imag({L1}(Z→B
:If 0<{L6}(T
:Then
:DelVar S
:Repeat not(S
:real({L3}(T→V
:imag({L3}(T→W
:A-V→X
:B-W→Y
:If X
:Then
:1+int(sqrt(X{^2}+Y{^2}→P
:tan{^-1}abs(Y/X→θ
:{L6}(T
:4randInt({-}10+Ans,10-Ans)+(X<0)(180-θ(Y>0)+θ(Y<0))+(X>0)(θ(Y>0)-θ(Y<0→θ
:If S
:Then
:DelVar SZ-1→Z
:real({L1}(Z→A
:imag({L1}(Z→B
:End
:Else
:If .5>abs(Y
:Then
:45→θ
:{L6}(T
:4randInt({-}10+Ans,10-Ans)+(Z≤8)(180-θ(Y>0)+θ(Y<0))+(X>Z)(θ(Y>0)-θ(Y<0→θ
:1+int(Y→P
:Else
:1→S
:Z+1→Z
:End
:End
:End
:End
:If not({L6}(T
:Then
:180(Z>8→θ
:Repeat K=21 and P
:getKey→K
:If K=45
:Goto N
:If K=25
:Then
:P+(P≠40→P
:51+P
:Line(Ans,57,Ans,59
:End
:Pt-Change(real({L3}(T)),imag({L3}(T
:{L2}(Z
:Line(A,B+.5Ans,A,B-.5Ans,I
:not(I→I
:If K=34
:Then
:51+P
:Line(Ans,57,Ans,59,not(P
:P-(P≠0→P
:End
:Line(87,7,87+6cos(θ),7+6sin(θ),not(K=24 or K=26
:θ+6(K=24 and θ≠360)-354(K=24 and θ=360)-6(K=26 and θ≠0)+354(K=26 and not(θ→θ
:End
:End
:RecallPic 1
:P+randInt({-}int(P/5),int(P/5→P
:real({L3}(T→X
:imag({L3}(T→Y
:For(P,P,0,{-}1
:Pt-Change(X,Y
:X→V
:Y→W
:X+cos(θ→X
:Y+sin(θ→Y
:seq((2^(I-1))(I≠T)not(iPart(2fPart({L5}(T)/(2^I))))(round(X,0)=round(real({L3}(I)),0) and round(Y,0)=round(imag({L3}(I)),0)),I,1,6
:If max(Ans
:Then
:sum(Ans)+{L5}(T→{L5}(T
:2→H
:randInt(0,1
:θ+(Ans-not(Ans))45→θ
:int(P/2→P
:End
:{L2}(Z
:round(WAns+Ynot(Ans),0
:If (not(fPart(Z/8)) or (Z<8 and (θ<90 or θ>270)) or (Z<16 and Z>8 and θ>90 and θ<270)) and round(Xnot({L2}(Z))+V{L2}(Z),0)=A and Ans≤B+.5{L2}(Z) and Ans≥B-.5{L2}(Z
:Then
:H+(H≠2→H
:0→{L5}(T
:Z→{L4}(T
:Z+1→Z
:If Ans=17
:Goto N
:real({L1}(Z→A
:imag({L1}(Z→B
:End
:If X>93 or X<1 or Y>61 or Y<1 or (X<23 and Y>45) or (X>79 and Y<15
:Then
:V→X
:W→Y
:{-}1→P
:DelVar H
:End
:X+Y{i}→{L3}(T
:End
:ClrDraw
:End
:Lbl N
:If Z=17
:Output(1,1,sub(Str1,4T-3,4)+" WINS!!!"
:DelVar Y1DelVar Pic1DelVar Str1DelVar {L1}DelVar {L2}DelVar {L3}DelVar {L4}DelVar {L5}DelVar {L6}Output(1,1,"
[edit]
Only found one optimization so far.....
Code:
:If not(H
:Then
:Repeat 0≤{L6}(T
:T+(T≠6)-5(T=6→T
:End