Computer Science Canada my connect 4 |
Author: | SuperGenius [ Tue Mar 09, 2004 8:24 pm ] | ||
Post subject: | my connect 4 | ||
This is my connect 4 project, which is finished, except that I wanted to allow the players to press y to begin another game without haveing to press run again for 3 reasons: 1. so they dont have to press run again 2. so they dont have to enter their names again 3. so that the program can keep a tally of how many games each player has won. the problem is that for some reason at the beginning of the second game the program is drawing a circle when it shouldn't be.
|
Author: | jonos [ Tue Mar 09, 2004 8:26 pm ] |
Post subject: | |
could you please inlcude the whole code, even the variables or else it will not work. you have 21 errors or seomting because of that. |
Author: | SuperGenius [ Tue Mar 09, 2004 8:29 pm ] |
Post subject: | |
oops... I thought I had copied everything but i guess not... ill just edit the first post instead of taking up more space. |
Author: | Paul [ Tue Mar 09, 2004 8:30 pm ] | ||||
Post subject: | |||||
Yes, do that, AND all those if statements are unneeded, like below:
can be
correct me if Im wrong. |
Author: | SuperGenius [ Tue Mar 09, 2004 8:37 pm ] |
Post subject: | |
i think you're correct so i made the fix you suggested, and the program still runs the same incorrect way it did before. |
Author: | Paul [ Tue Mar 09, 2004 8:51 pm ] | ||
Post subject: | |||
Well, you I think you should be using recursion to do this (though I have no idea how to use recursion), but I think I figured out the problem, I think the program isn't even putting the "RED" or "GREEN" into the arrays, I added
right after the wincheck in you main loop, and nothing shows up, when you have a red piece in (8,1) |
Author: | SuperGenius [ Tue Mar 09, 2004 8:58 pm ] | ||||
Post subject: | |||||
Paul Bian wrote:
this just screws it up, becuase the array holds blank spaces at the start, and as you play the array is changed to either "RED" of "GREEN", and there is a procedure that will update the board like so...
trying to put out board(8,1) wont work because i used a little formula to find the right place and then draw a circle of either colour in it based on the contents of the 'board' array. |
Author: | Paul [ Tue Mar 09, 2004 9:02 pm ] |
Post subject: | |
oh I see, that would complicate things cause I thought it was like this your program checks the text inside each variable in the array? so if I played on col 1, then the variable (8,1) would change from " " to RED, wouldn't it? so then you check every variable in the 2D array, and when it gets to 8,1 it should find RED right? but it doesn't, though my way of checking might be wrong. |
Author: | SuperGenius [ Tue Mar 09, 2004 9:07 pm ] |
Post subject: | |
Paul Bian wrote: so if I played on col 1, then the variable (8,1) would change from " " to RED, wouldn't it?
i think (1,1) would change for the first play in col 1, but im not sure... i tried your suggestion with (1,1) instead and it returns RED... so the problem is not in the contents of the array for sure... becuase it it wasnt updating the array with "RED" and "GREEN" then it wouldnt be drawing the circles either |
Author: | Paul [ Tue Mar 09, 2004 9:21 pm ] | ||||||
Post subject: | |||||||
OMFG, it freaking works, just change the checking code a bit, OMGI I cant believe this
even if it won, which it did for me, we wouldn't see it, cause it restarts so fast!!! god, I put a delay on it and it worked, it worked in the first place, just check it with this: because it changes from 1, 1 to 2, 1 and so on
by putting 4 pieces vertically into the first column!!! all this discussion has been totally useless here just change your checking coding to this:
and it works perfectly... just not for diagonally. |
Author: | SuperGenius [ Tue Mar 09, 2004 9:27 pm ] |
Post subject: | |
holy shit.... the little things like this have a way of biting me in the ass... but thank you for pointing it out to me before I went crazy. thanks again |
Author: | white_dragon [ Wed Mar 10, 2004 5:55 pm ] |
Post subject: | |
haha lol. paul's the real genius ![]() |
Author: | SuperGenius [ Wed Mar 10, 2004 7:47 pm ] |
Post subject: | |
you better tell me why you are called white dragon or i'll have to find it out from someone else |
Author: | SuperGenius [ Thu Mar 11, 2004 4:55 pm ] |
Post subject: | |
hey guys.... ive got another little problem... if anyone would like to help me with it that would be awesome. ive updated my 1st post with the new source to conserve space. |
Author: | Paul [ Thu Mar 11, 2004 5:02 pm ] | ||
Post subject: | |||
First: Press alt+c before you post your code Second: You didn't state your problem. Third: I think I know what your problem is. When a person wins, and you want to play again, it automatically screws up. That is because you didn't reset the variables. And the 2 D array is still filled, and so it wins automattically when you restart. Empty your variables with something like this:
when the user chooses Y for play again. |
Author: | SuperGenius [ Thu Mar 11, 2004 8:01 pm ] |
Post subject: | |
thanks again.... i knew in the back of my brain that the invisible error was going to be painfully obvious to someone else... I am disgusted with myself lol, but once again thanks |
Author: | SuperGenius [ Thu Mar 11, 2004 8:56 pm ] |
Post subject: | |
i think the problem with the phantom circle was becuse the value for var act was not being reset fast enough because of the delay inside the flash process was too long so i just tightened that up and it seems to be working. I feel like a champ now. |