Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.

Code:
ClrDraw:AxesOff
GridOff:BackgroundOff
0->Xmin:0->Ymin
264->Xmax:164->Ymax

Line(5,117,149,117,1,19,2
Line(5,1,149,1,1,19,2
Line(5,1,5,117,1,19,2
Line(149,1,149,117,1,19,2
For(F,12,107,19
For(P,17,149,20
Circle(P,F,08,19
End:End
For(F,7,147,20
Line(F,1,F,117,1,19,2
End
For(F,2,116,19
Line(5,F,149,F,1,19,2
End


So far, that's what I've managed to write to generate the playing field. It takes quite a while. Here is the end result thus far:



Selection will be above the board, text for whose turn it is to the right of.

I'm just curious, should I try to come up with code to fill in the little spots, or just leave it and move on to figuring out how to shade in each of those circles with red and black? :)


Edit:

From here I found the fill in circle routine. It's not perfect, but does a good enough approximation for now. I've determined the following for the bottom left:

8->R
23->X
12->Y

To move up 1, it's 31->Y. To move right one, it's 45->X. This gives me base numbers to move things around with :)

I'm thinking of using a list to handle the 0's, 1's and 2's, but haven't fully set on that. I think on the one side, it'll make things faster and smaller, but matrices would definitely be easier to keep track of. Just something I'm messing with in my thinking.
Looks good, but I would definitely change the background color if you're going to use yellow.
Got any suggestions that isn't red or black, that would look good with yellow? lol

I'll play with it, see what I can figure out Smile
If it helps, here's a routine that would draw both the circle and the square area around it, using your existing F and P values.

Code:
:For(A,~9,9
:Line(P-9,F+A,P-sqrt(81-A^2),F+A,1,19
:Line(P+9,F+A,P+sqrt(81-A^2),F+A,1,19
:End


I think this should work. Edit: regarding colors, how about orange instead of yellow?

Edit: Faster and smaller:

Code:
:For(A,~9,9
sqrt(81-A^2
:Line(P-9,F+A,P-Ans,F+A,1,19
:Line(P+9,F+A,P+Ans,F+A,1,19
:End
Gray should look fine.
Grey does work! And Yellow because that's what the original board color was Smile

Edit:

Oooh, looking nice. You can easy fix that column if you so decide, but it looks kinda nice that way to me.
Ooh, that looks very nice! You should make a grayscale chess game to rival thepenguin77's, too >.>
I agree as well! If you look at images of Connect 4 on google, you can plainly see those dividers as well. Smile

Now to work on other things, like making things work! Very Happy

Edit: lol Xeda, I'm thinking that needs ASM. I'm just a silly BASIC coder Wink
tifreak8x wrote:
I agree as well! If you look at images of Connect 4 on google, you can plainly see those dividers as well. Smile

Now to work on other things, like making things work! Very Happy

Edit: 0x5 Xeda, I'm thinking that needs ASM. I'm just a silly BASIC coder Wink
Not anymore! Very Happy That's the beauty of the TI-84 Plus C Silver Edition. I bet the logic might be slow in TI-BASIC for an AI, though. Sad
Not if you have grayscale at your disposal Very Happy And yes, those dividers do make it look nice. It is a small detail, but it makes it look more real.
I'm giving thoughts to that as well. I -think- I might have a solution, but I won't know until I make this workable. Smile
After spending a couple hours on this code, and with the help of Kerm for getting the rendering to go a bit faster, I have this:



What this does currently is move the colored token back and forth across the top, and drop in the first slot. For some reason, it's not working in the others. It does, however, properly stack. Smile

I'll need to write in some more diagnostic stuff so I can figure out what else is going on.

Code currently:


Code:
ClrDraw:AxesOff
GridOff
BackgroundOnMedGray
0->Xmin:0->Ymin
264->Xmax:164->Ymax
SetUpEditor L1
42->dim(L1
Fill(0,L1
Line(5,117,148,117,1,19,2
Line(5,1,148,1,1,19,2
Line(5,1,5,117,1,19,2
Line(148,1,148,117,1,19,2
For(F,12,107,19
For(P,17,149,20
For(A,~9,9
sqrt(81-A^^2
Line(P-9,F+A,P-Ans,F+A,1,19
Line(P+9,F+A,P+Ans,F+A,1,19
End:End:End
1->W:0->U:7->R
While iPart(W)=1
If fPart(W)=0:Then:17->A:126->B:End
For(F,0,R,DeltaX
sqrt(R^2-F^2
Line(A+F,B+Ans,A+F,B-Ans,1,11+U,1
Line(A-F,B+Ans,A-F,B-Ans,1,11+U,1
End
2->W
While W=2
getKey->K
If max(K={21,24,26,22
Then
For(F,0,R,DeltaX
sqrt(R^2-F^2
Line(A+F,B+Ans,A+F,B-Ans,0
Line(A-F,B+Ans,A-F,B-Ans,0
End
If K=24 or K=26:Then
A-20((K=24 and A>17)-(K=26 and A<155->A
1.1->W:End
If K=22:Then
ClrDraw:BackgroundOff:DelVar ADelVar FDelVar ZDelVar KDelVar MDelVar LDelVar PDelVar RDelVar thetaDelVar UDelVar WDelVar L1
End
If K=21:Then
(A+3)/20->L
(B-12)/19->Z
(6L)-5->M
If L1(M)=0:Then
While Z>1 and L1(M+1)=0
Text(1,1,Z
For(F,0,R,DeltaX
sqrt(R^2-F^2
Line(A+F,B+Ans,A+F,B-Ans,0
Line(A-F,B+Ans,A-F,B-Ans,0
End
B-19->B:M+1->M
(B+7)/19->Z
If Z=2 and L1(M)!=0:U->L1(M
For(F,0,R,DeltaX
sqrt(R^2-F^2
Line(A+F,B+Ans,A+F,B-Ans,1,11+U,1
Line(A-F,B+Ans,A-F,B-Ans,1,11+U,1
End:End
U+1->L1(M
U+((U=0)-(U=1->U
1->W
End:End:End
End
End:"W=1


I'll begin tracking down that bug sometime tomorrow.


http://tifreakware.net/tifreak8x/connect4/BA.8xp
Any particular rationale as to why you're representing the board as a list rather than a matrix or string? Just curious! Smile
I'm glad you were able to be productive on HCWP, tifreak8x! As I asked you there, I'll do my best not to pick through this for optimizations yet. I tried to spot your bug, but to no avail.

Edit: I second Elfprince's question; a matrix would make this much easier.
I can think that lists might make general formulas to find 4-in-a-row easier (on diagonals, for example), but I'm not sure. That's what I was asking.
I haven't really used a matrix in a very long time. My experiences with them led me to the facts that

1) Matrices consume a ton of memory very quickly

2) Matrices are a lot slower to deal with than lists, plus take more code to do checks and such for.

Appreciate the support, guys Smile

@Kerm: The reason I don't want help with optimizations at this stage is because the code is far from ready to be optimized. I never worry about optimized code at this point, I just want the thing to work. Once this thing is fully playable, then I can go through and optimize, and ask for help. I'd feel bad if you optimized code, and I had to change it to make something else work down the road and break things Smile

Edit:



Here is an animated. The line isn't missing in the center of the circles, obviously, and it is a little faster than shown in the shot. It takes a little under 40 seconds to render the board. Smile

Edit 2:

I've managed to get it to drop pieces in every section except the last column. :/ It has to do with the list elements going beyond what it is supposed to. The dim( is supposed to be 42, and it keeps going for 43.

Edit 3:

I've gotten it to drop down on the right side all the way without erroring, but now it isn't stopping when it hits to a point where there is one under neath it. Still checking stuff out..
So, for drawing the board it looks like you have some sort of for loop for the squares that is doing some calculations and going all the way through. You can probably take advantage of the symmetry and and only do a quarter of the calculations. For dropping, I probably wouldn't animate it dropping, just for the sake of time.
tifreak8x wrote:
I haven't really used a matrix in a very long time. My experiences with them led me to the facts that

1) Matrices consume a ton of memory very quickly
It can appear so, because squarish matrices grow by O(n^2), but they consume exactly the same amount of memory as lists. An N-element list consumes 9N+a few bytes, say 9N+16 to account for the size bytes and the VAT entry. An NxM matrix takes 9(NxM)+a few bytes, say 9(NxM)+16 bytes. If you need 6x6 elements, you either need a 36-element list or a 6x6 matrix, both of which are going to be about 340 bytes.

Quote:
2) Matrices are a lot slower to deal with than lists, plus take more code to do checks and such for.
For this program, I believe matrices would be faster and require less code.

Quote:
Appreciate the support, guys Smile

@Kerm: The reason I don't want help with optimizations at this stage is because the code is far from ready to be optimized. I never worry about optimized code at this point, I just want the thing to work. Once this thing is fully playable, then I can go through and optimize, and ask for help. I'd feel bad if you optimized code, and I had to change it to make something else work down the road and break things Smile
That makes perfect sense; premature optimization is a bad idea in most languages and projects. Smile
Yeah, I might see about implementing the matrix setup. Might eliminate some of the headaches that I've almost got taken care of :p

Edit:

Also, because Text( fails with backgrounds (Maybe pass that on to TI, about maybe doing better overlaying of characters from the Text( command on backgrounds for the next OS update?), I'm thinking about going with no brackground, and a blue board. What are your all thoughts on this?
  
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 3
» All times are GMT - 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