0 Members and 3 Guests are viewing this topic.
Ok. So I decided to completely do a rewrite of my Battle Ship program because I thought it was to big and just wasn't satisfied with it. I was also to lazy to just go back and rework the code to work. But anywho, to the program.I did succeed in making this one smaller by about 62 bytes while still making it better than the previous version (it stands at 990 bytes). It should work perfectly now but if anyone discovers a bug please let me know. [2ND] - It is the enter button.[ALPHA] - When setting the maps this is what flips it between vertical and horizontal movement.[ENTER] - Used to exit the Pause after turns. This version fixes the previous bugs that I knew about. Like I said before if you find one just tell me and I'll try to fix it.I can't think of much else to say so I'll let you guys to it. Have fun and enjoy.Here is the source code in case anyone else can find optimizations. I'm very tired so there is a chance I missed something.Spoiler For To Keep it Shorter: Code: (Battle Ship Final) [Select]ClrHome"3221110000→Str2"MH →Str10identity(16→[A]DelVar TDelVar SDelVar LRepeat S=20 and T=20ClrHomeFor(A,1,8Output(A,9-8L,"++++++++EndOutput(1,9-8L,"PLAYEROutput(1,16-8L,L+11→X1→YDelVar G1→RRepeat R=11Repeat K=21For(A,0,expr(sub(Str2,R,1Output(X+AG,Y+Anot(G)+8L,sub("* ",2-[A](X+AG,Y+Anot(G)+8L),1EndIf Ans=31not(G→Gmin(8-Gexpr(sub(Str2,R,1)),max(1,X+sum(DeltaList(K={25,34→Xmin(8-not(G)expr(sub(Str2,R,1)),max(1,Y+sum(DeltaList(K={24,26→YFor(A,0,expr(sub(Str2,R,1Output(X+AG,Y+Anot(G)+8L,"*EndRepeat AnsgetKey→KEndEndDelVar HFor(A,0,expr(sub(Str2,R,1H+[A](X+AG,Y+Anot(G)+8L→HEndIf not(HThenFor(A,0,expr(sub(Str2,R,11→[A](X+AG,Y+Anot(G)+8LEndIf LT+1+expr(sub(Str2,R,1→TIf not(LS+1+expr(sub(Str2,R,1→SR+1→REndEndnot(L→LEnd1→XAns→YrandInt(0,1→LLbl 1Repeat S=0 xor T=0ClrHomeFor(A,1,8Output(A,1+8L,"++++++++EndOutput(1,1+8L,"PLAYEROutput(1,8+8L,L+1For(A,1,8For(B,9-8L,16-8LOutput(A,B,sub(Str1,4-[A](A,B),1EndEnd1→X9→YRepeat K=21Output(X,Y-8L,sub(Str1,4-[A](X,Y-8L),1min(8,max(1,X+sum(DeltaList(K={25,34→Xmin(16,max(9,Y+sum(DeltaList(K={24,26→YOutput(X,Y-8L,"SOutput(3,4+8L,sub("ABCDEFGH",X,1Output(3,5+8L,Y-8Repeat AnsgetKey→KEndEndIf 1<[A](X,Y-8LThenOutput(5,1+8L,"TRYOutput(6,4+8L,"AGAINPause Goto 1EndIf not([A](X,Y-8LThenOutput(5,3+8L,"MISS3→[A](X,Y-8Lnot(L→LPause Goto 1EndIf 1=[A](X,Y-8LThenOutput(5,3+8L,"HIT!If LT-1→TIf not(LS-1→S2→[A](X,Y-8Lnot(L→LPause EndEndEndDelVar [A]ClrHomenot(L→LOutput(4,5,"PLAYEROutput(4,12,L+1Output(5,7,"WON!
ClrHome"3221110000→Str2"MH →Str10identity(16→[A]DelVar TDelVar SDelVar LRepeat S=20 and T=20ClrHomeFor(A,1,8Output(A,9-8L,"++++++++EndOutput(1,9-8L,"PLAYEROutput(1,16-8L,L+11→X1→YDelVar G1→RRepeat R=11Repeat K=21For(A,0,expr(sub(Str2,R,1Output(X+AG,Y+Anot(G)+8L,sub("* ",2-[A](X+AG,Y+Anot(G)+8L),1EndIf Ans=31not(G→Gmin(8-Gexpr(sub(Str2,R,1)),max(1,X+sum(DeltaList(K={25,34→Xmin(8-not(G)expr(sub(Str2,R,1)),max(1,Y+sum(DeltaList(K={24,26→YFor(A,0,expr(sub(Str2,R,1Output(X+AG,Y+Anot(G)+8L,"*EndRepeat AnsgetKey→KEndEndDelVar HFor(A,0,expr(sub(Str2,R,1H+[A](X+AG,Y+Anot(G)+8L→HEndIf not(HThenFor(A,0,expr(sub(Str2,R,11→[A](X+AG,Y+Anot(G)+8LEndIf LT+1+expr(sub(Str2,R,1→TIf not(LS+1+expr(sub(Str2,R,1→SR+1→REndEndnot(L→LEnd1→XAns→YrandInt(0,1→LLbl 1Repeat S=0 xor T=0ClrHomeFor(A,1,8Output(A,1+8L,"++++++++EndOutput(1,1+8L,"PLAYEROutput(1,8+8L,L+1For(A,1,8For(B,9-8L,16-8LOutput(A,B,sub(Str1,4-[A](A,B),1EndEnd1→X9→YRepeat K=21Output(X,Y-8L,sub(Str1,4-[A](X,Y-8L),1min(8,max(1,X+sum(DeltaList(K={25,34→Xmin(16,max(9,Y+sum(DeltaList(K={24,26→YOutput(X,Y-8L,"SOutput(3,4+8L,sub("ABCDEFGH",X,1Output(3,5+8L,Y-8Repeat AnsgetKey→KEndEndIf 1<[A](X,Y-8LThenOutput(5,1+8L,"TRYOutput(6,4+8L,"AGAINPause Goto 1EndIf not([A](X,Y-8LThenOutput(5,3+8L,"MISS3→[A](X,Y-8Lnot(L→LPause Goto 1EndIf 1=[A](X,Y-8LThenOutput(5,3+8L,"HIT!If LT-1→TIf not(LS-1→S2→[A](X,Y-8Lnot(L→LPause EndEndEndDelVar [A]ClrHomenot(L→LOutput(4,5,"PLAYEROutput(4,12,L+1Output(5,7,"WON!
wow nice update! Pretty small too. I agree it's hard to keep a lot of games under 1 KB. I myself often had an hard time doing it with anything other than tunnel