I am finally going to release version 1.0 of Tic Tac Toe 1000. It is at 2.2k all in one easy to download program so it is easy to use with DCS7. This is the current screenshot. I am going to add a few bytes to place the number of ties and look over the program a few more times as well as play it to make sure that there are no errors. I might even find a way to decrease it by a few bytes. I will upload my version of TicTacToe 1000 V1.0 in one week.





Does it have a 1 player mode and a 2 player mode? I <3 the UI, btw. Smile
souvik1997 wrote:
Does it have a 1 player mode and a 2 player mode? I <3 the UI, btw. Smile

No, I will not be making any two player games at this time, sorry. What do think would make the UI better. I could make some graphics if you think it would matter. I really don' t know why it should be anymore extravagant for this type of game. It has a directional cursor for placement and it has a good opponent. It's TicTacToe. Would you rather play with pieces other than X and O.
It looks quite nice and minimalistic right now, I don't think you should change it IMO.
I am very glad that you like it souvik1997. I am posting the code here so you can take a look at it. I see some errors and a few things I need to change now that its on a big screen. Let me know what you think. Comments welcome. Smile

Code:
:AxesOff
:GridOff
:PlotsOff
:Full
:ZDecimal
:{‾.1,‾.2,‾.2,‾.3,‾.3,‾.3,‾.4,‾.4,‾.4,‾.5,‾.5,‾.6}→L3
:{‾2.1,‾2.2,‾2,‾2.3,‾2.1,‾1.9,‾2.3,‾2.1,‾1.9,‾2.2,‾2,‾2.1}→L4
:Plot1Scatter ,L4,L3,∙
:DelVar B
:Lbl O
:Text(15,26,"TIC - TAC - TOE
:Text(32,32,"NEW
:Text(45,32,"CONTINUE
:Lbl O1
:getKey→A
:If A=34 and B=0:Then:1→B
:¦ L3-1.5→L3
:¦ Goto O
:End
:If A>0 and A≠34 and A≠25 and B=0:Then
:¦ DelVar D
:¦ Goto Q
:End
:If A=25 and B=1:Then:L3+1.5→L3
:¦ DelVar B
:¦ Goto O
:End
:If A>0 and A≠25 and A≠34 and B=1:Then
:¦ 1→D
:¦ Goto Q
:End
:Goto O1
:Lbl Q
:ClrDraw
:If D=1:Goto C
:0→dim(∟TICY
:2→dim(∟TICY
:Lbl C
:0→dim(L5
:11→dim(L5
:0→dim(L2
:9→dim(L2
:PlotsOff
:ClrDraw
:‾2.2→G:2.6→H
:While G<3.8
:¦ Line(G,2.6,G,‾2:G+1.5→G
:End
:2.6→G
:While G>‾3.4
:¦ Line(‾2.2,G,2.3,G:G-1.5→G
:End
:StorePic 9
:DelVar WDelVar QDelVar R
:Lbl A
:20→M:2→N:2→O:2→P
:{.8,.8,.7,.7,.6,.6,.5,.5,.4,.4,.3,.3,.2,.2,.1,.1,0,0,‾.1,‾.1,‾.2,‾.2}→L3
:{‾.5,.6,‾.4,.5,‾.3,.4,‾.2,.3,‾.1,.2,0,.1,‾.1,.2,‾.2,.3,‾.3,.4,‾.4,.5,‾.5,.6}→L4
:PlotsOn2
:DelVar GDelVar H:For(G,1,9:L2G+H→H:End:If H≥13:Goto C
:1→G
:While G≠10
:¦ If L2(G)+L2(G+1)+L2(G+2)=6:2→W
:¦ G+3→G:End:1→G
:While G≠4
:¦ If L2(G)+L2(G+3)+L2(G+6)=6:2→W:G+1→G:End
:If L2(1)+L2(5)+L2(9)=6:2→W
:If L2(7)+L2(5)+L2(3)=6:2→W
:
:If W=2:Then
:¦ 1+∟TICY(2→∟TICY(2
:¦ While 1
:¦ ¦ PlotsOff
:¦ ¦ Text(30,35,"YOU LOST
:¦ ¦ getKey→A
:¦ ¦ If A>0
:¦ ¦ Goto C
:¦ End
:End
:Lbl O4
:RecallPic 9
:Text(10,1,"WIN
:Text(17,1,∟TICY(1
:Text(10,75,"LOSE
:Text(17,75,∟TICY(2
:getKey→A
:If A=34 and M≠30:Then
:¦ L3-1.5→L3:M+10→M:End
:If A=25 and M≠10:Then
:¦ L3+1.5→L3:M-10→M:End
:If A=26 and N≠3:Then
:¦ L4+1.5→L4:N+1→N:End
:If A=24 and N≠1:Then
:¦ L4-1.5→L4:N-1→N
:End
:If A>0 and A≠34 and A≠25 and A≠24 and A≠26:Then:DelVar G10→H:For(G,1,10:If G=4:20→H:If G=7:30→H:1+H→H:If M+N=H and L5(G)≠H:Then:1→L2(G:H→L5(G:StorePic 9:Goto B
:¦ ¦ End:End
:End
:Goto O4
:Lbl B
:{‾.2,‾.1,0,.1,.2,.3,‾.3,.4,‾.4,.5,‾.5,.6,‾.5,.6,‾.5,.6,‾.5,.6,‾.5,.6,‾.4,.5,‾.3,.4,‾.2,‾.1,0,.1,.2,.3}→L4
:{.8,.8,.8,.8,.8,.8,.7,.7,.6,.6,.5,.5,.4,.4,.3,.3,.2,.2,.1,.1,0,0,‾.1,‾.1,‾.2,‾.2,‾.2,‾.2,‾.2,‾.2}→L3
:1→G
:While G≠10
:¦ If L2(G)=1 and L2(G+1)=1 and L2(G+2)=1:1→W:G+3→G
:End:1→G
:While G≠4
:¦ If L2(G)=1 and L2(G+3)=1 and L2(G+6)=1:1→W:G+1→G:End
:If L2(1)=1 and L2(5)=1 and L2(9)=1:1→W
:If L2(3)=1 and L2(5)=1 and L2(7)=1:1→W
:If W=1:Then:PlotsOff:Text(30,35,"YOU WON
:¦ 1+∟TICY(1→∟TICY(1
:¦ While 1
:¦ ¦ getKey→A
:¦ ¦ If A>0:Goto C
:¦ End
:End
:randInt(1,9→C
:DelVar GDelVar H:For(G,1,9:L5(G)+H→H:End:If H≥198:Goto C
:DelVar G:For(G,1,3:If L2(G)=0 and L2(1+G)=1 and L2(2+G)=1:G→C:End
:For(G,3,1:If L2(G)=1 and L2(G+1)=0 and L2(G+2)=1:G+1→C:End
:For(G,1,3:If L2(G)=1 and L2(G+1)=1 and L2(G+2)=0:G+2→C:End
:DelVar G:10→H
:While G≠10:G+1→G:H+1→H:If C=G and L5(G)=H:Goto B:If H=13:20→H:If H=23:30→H:End
:DelVar G:10→H:While G≠10:G+1→G:H+1→H:If C=G and L5(G)≠H:Then:H→L5(G):Goto E:End:If H=13:20→H:If H=23:30→H:End
:End
:Goto B
:Lbl E
:DelVar J
:L5(G)→H:2→L2(G
:If H>30:Then
:¦ 3→J:H-30→H:End
:If H<20:Then:1→J:H-10→H:End
:If H>20:H-20→H
:If J=3:L3-1.5→L3:If J=1:L3+1.5→L3:If H=1:L4-1.5→L4:If H=3:L4+1.5→L4:RecallPic 9:StorePic 9:Goto A

A note for future reference, the code
Code:
:0→dim(L5
:11→dim(L5
:0→dim(L2
:9→dim(L2
is equivalent to
Code:
:11->dim(L5
:Fill(0,L5
:9->dim(L2
:Fill(0,L2
Also, on lines like this:
Code:
:If L2(1)=1 and L2(5)=1 and L2(9)=1:1→W
:If L2(3)=1 and L2(5)=1 and L2(7)=1:1→W
you can rearrange the last clause to be 1=L2(7:1->W to save one byte.
KermMartian wrote:
A note for future reference, the code

Thank you very much for saving me more bytes. I will take note of that; one byte adds up. I am suprised that you did not mention anything about the double code or extra variables. I was going to use them for something else but I decided against it. Added the cursor. It should be a little smaller I think. I think it should be under 2k. Will see, have not rearranged code and deleted code yet
I didn't want to mention too many things at once, because I assumed you'd be looking for improvements and optimizations on your own as well. You really, really should be using a loop instead of Lbl O4, for instance; I'd be happy to show you what to do about that.
I did not get a chance to work on this program as much as I would have liked to. My grandfathers funeral is today so it has been hard to find time this week but I am releasing it as promised. The program is at 2.3k, it runs good, I think it is a good release. KermMartian if you would not mind showing me an example of this I would like to see it. I think it would be beneficial to me, and the files I will be uploading to the archives.
The code below demonstrates a memory leak; notice that you're three levels deep into an If/For/If construct, which is very bad.


Code:
:Lbl O4
:...code...
:If A>0 and A≠34 and A≠25 and A≠24 and A≠26
:Then
:DelVar G10→H
:For(G,1,10
:If G=4:20→H
:If G=7:30→H
:1+H→H
:If M+N=H and L5(G)≠H
:Then
:1→L2(G:H→L5(G
:StorePic 9:Goto B
:End
:End
:End
:Goto O4
:Lbl B
A much cleaner method would be this, which does not have a memory leak:
Code:
DelVar D:Repeat D
:...code...
:If A>0 and A≠34 and A≠25 and A≠24 and A≠26
:Then
:DelVar G10→H
:For(G,1,10
:If G=4:20→H
:If G=7:30→H
:1+H→H
:If M+N=H and L5(G)≠H
:Then
:1→L2(G:H→L5(G
:StorePic 9:1→D
:End
:End
:End
:End
KermMartian wrote:
The code below demonstrates a memory leak; notice that you're three levels deep into an If/For/If construct, which is very bad.

Well, that is exactly why I joined Cemetech. I am wondering why I have not noticed any problems with it. I let my son play it for about 2 hrs and I have played it as well. It seems to be virtually error free. Thank you for letting me know that.
My pleasure. Smile Does that piece of code that I picked on not get executed very often? It won't cause problems if runs one or two times, more like a few hundred.
It runs once every pass which would cause it to be executed 5 times a game.
basicman wrote:
It runs once every pass which would cause it to be executed 5 times a game.
Then you more or less wouldn't notice the slowdown from the memory leak. Smile
Still, you should change it because memory leaks are generally regarded as bad programming habits.
souvik1997 wrote:
Still, you should change it because memory leaks are generally regarded as bad programming habits.

I agree with this. It only seems fair to everyone that they need not worry about such things in a program, and it could cause others to program the same way. Thanks.
souvik1997 wrote:
Still, you should change it because memory leaks are generally regarded as bad programming habits.
Indeed, and it's better to fix it anyway in case you make this program more complex in the future.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement