Have you ever played the game Snake and always lost because of there being no pause function?
Now, with your help, you all at TI-BASIC Developer can mod a game to include a fantastic AI system!
This is a very bad solution I came up with, but I did this only a few minutes ago.
:AxesOff:FnOff :ClrDraw :ZStandard :104→Xmax :‾72→Ymin :ZInteger :Line(94,0,94,‾61 :Line(0,0,0,‾61 :Horizontal 0 :Horizontal ‾61 :41→A:Ans→E :29→B:Ans→F :1→H:0→V :5→S:0→θ :Pt-On(41,‾29,2 :Repeat not(pxl-Test(N-1,M-1 :2+3int(31rand→M :2+3int(20rand→N :End :Pt-On(M,‾N,2 :Pt-Off(M,‾N,3 :Pxl-On(N,M :Repeat 0 :If 1=abs(K-25 :Then :25(N<B)+34(N>B→K :Else :24(A>M)+26(A<M→K :End :If Ans:Then :If H:Then :(Ans=34)-(Ans=25→V :If Ans :0→H :Else :(Ans=26)-(Ans=24→H :If Ans :0→V :End :End :If H:Then :A+3H→A :If pxl-Test(B,Ans-H) :Then :Text(27,34,"SCORE:",θ :Return :End :Pt-On(Ans,‾B,2 :Pxl-Off(B,Ans-H :Pxl-Off(B,Ans-2H :Else :B+3V→B :If pxl-Test(Ans-V,A:Then :Text(27,34,"SCORE:",θ :Return :End :Pt-On(A,‾Ans,2 :Pxl-Off(Ans-V,A :Pxl-Off(Ans-2V,A :End :If pxl-Test(B,A :Then :Pxl-Off(B,A :Repeat not(pxl-Test(N-1,M-1 :2+3int(31rand→M :2+3int(20rand→N :End :Pt-On(M,‾N,2 :Pt-Off(M,‾N,3 :Pxl-On(N,M :If θ=95:Then :Text(27,34,"WIN. :Return :End :Pxl-On(62,θ :1+θ→θ :S+3→S :End :If S:Then :S-1→S:Else :pxl-Test(F,E-1)-pxl-Test(F,E+1 :If Ans:Then :Pxl-On(F,E+2Ans :Pt-Off(E,‾F,2 :E+3Ans→E :Else :1-2pxl-Test(F+1,E :Pxl-On(F+2Ans,E :Pt-Off(E,‾F,2 :F+3Ans→F :End :End :End
It simply moves in a zigzag to the food, and doesn't care about colliding into walls, and if it is in line with the food and going in the opposite direction, it just crashes into a wall.
I want the snake to move in a constant pattern that covers the entire board. I found one that exists, but my algorithm is way off. Can anyone propose a different solution?
:ClrHome:Disp "HOW DOES A","MATHEMATICIAN","LOSE WEIGHT? :Pause " :Pause "BINOMIALS! :Pause "(BUY NO MEALS)":ClrHome