Computer Science Canada School Project.... PLEASE help |
Author: | enjoy [ Tue Nov 09, 2004 11:40 am ] | ||
Post subject: | School Project.... PLEASE help | ||
i did this much... but the program is not working the way i wanted to work!!! .... could any please help me ?? its a tic tac toe game but not working properly this is the code!
|
Author: | McKenzie [ Tue Nov 09, 2004 1:57 pm ] | ||||
Post subject: | |||||
The way you are keeping track of who has taken a spot is odd. Currently you are implementing them as counters. What you want instead is to remember who has taken a spot. You could use numbers for this if you like. e.g. 0=empty 1=X 2=O so when X takes the spot use :
make sure also that before you let someone take a spot that it is empty e.g.
note: Your style needs some work. Although this program is best done with 2-Dim arrays you would be in better shape if you chose better variable names. |
Author: | myob [ Tue Nov 09, 2004 8:08 pm ] | ||
Post subject: | |||
this is what i would do if im going to make a tic tac toe game, i know its not all error trapped and stuff but it gives u an general idea of how things are traced and etc. when u want to trace which block has which, just make an int variable for that block, and if its blank, value = 0, if has x, value = 1, if has o, value = 2. then it is easy to trace and u can even make the computer to automatically determine the winner.
|
Author: | enjoy [ Tue Nov 09, 2004 10:52 pm ] |
Post subject: | thanx |
thanx for ur suggestions.... i really appretiate it could some on plz tell me how i can make it more effeicient... may be by using 2-d array.... and i also have to make it so that the user can play with the computer (different levels) ??? |
Author: | Cervantes [ Wed Nov 10, 2004 4:00 pm ] |
Post subject: | |
If you want to use 2D arrays, learn to use arrays here or here. |
Author: | Mr. Glib [ Wed Nov 10, 2004 6:00 pm ] |
Post subject: | |
enjoy, why not use a 2-d array to keep track of player moves? Set a 2-d array (3 row, 3 cols) to a bunch of zeros. If the user selects a spot, that position's value in your array is set to one (or some other value). You'll have to check with some sort of if block to ensure that only valid moves are made. If you want to keep track of who wins why not use a magic square? 7 | 2 | 3 0 | 4 | 8 5 | 6 | 1 If the player's total = 12 then they won (be careful, you'll have to check to see if there is a winning combo in each row, col and diagonal. |
Author: | enjoy [ Wed Nov 10, 2004 6:13 pm ] |
Post subject: | thanx Mr. Glib |
hey Mr. Glib.... could u please make a small coding that would do that for plz... cuz i don't know where to start form!! and guys i wanna use the mouse.where code but i have never used it before so could u guys plz show me how to do it.... thanx alot i really appretiate ur help |
Author: | Cervantes [ Wed Nov 10, 2004 6:34 pm ] |
Post subject: | |
well, you could mosie on over to the Turing Tutorials section and read a Mouse.Where Tutorial. |
Author: | myob [ Wed Nov 10, 2004 6:42 pm ] | ||
Post subject: | |||
or, just do what i said earlier. set value of the array to zero if nothing in it, set it to 1 if player 1, set it to 2 if player 2. so like this box 1|2|1 2|1|2 2|1|1 i wrote down the codes to check whoever wins the game, anymore codes from me basically will mean that i made the game for you
|
Author: | Mr. Glib [ Wed Nov 10, 2004 7:20 pm ] | ||||||||||
Post subject: | |||||||||||
Looks like I was beaten to the punch! To check for a winning move, you'll have to create a 2-D array for the magic sqaure grid I mentioned above:
Create 2 more 2-d arrays to keep track of each player's magic square #s:
here's a sample array to keep track of spots on the grid that are taken:
Now if some chooses one of the spots in your game:
To find a winner:
|
Author: | eNc [ Wed Nov 10, 2004 8:09 pm ] | ||
Post subject: | Re: School Project.... PLEASE help | ||
enjoy wrote: i did this much... but the program is not working the way i wanted to work!!! .... could any please help me ??
its a tic tac toe game but not working properly this is the code!
LOL omg I know you go to NOrth Toronto CI, and Mr. Small is your teacher and your in gr 10... LOL |
Author: | myob [ Wed Nov 10, 2004 10:56 pm ] | ||||||||||
Post subject: | |||||||||||
Mr. Glib wrote: Looks like I was beaten to the punch!
To check for a winning move, you'll have to create a 2-D array for the magic sqaure grid I mentioned above:
Create 2 more 2-d arrays to keep track of each player's magic square #s:
here's a sample array to keep track of spots on the grid that are taken:
Now if some chooses one of the spots in your game:
To find a winner:
to my best understanding, we have almost the same concept except u use magic squares and i use 0,1,2. |
Author: | enjoy [ Thu Nov 11, 2004 3:42 pm ] |
Post subject: | |
thanx guys.... but there is a small problem!! myob... u know ur code always indecates that it is a tie game... Mr. Glib... urs i don't even know how to use ... i don't know wat is happening there... eNc... very funny |
Author: | enjoy [ Thu Nov 11, 2004 3:44 pm ] |
Post subject: | |
Quote: Looks like I was beaten to the punch!
To check for a winning move, you'll have to create a 2-D array for the magic sqaure grid I mentioned above: Code: var magicSq : array 1..3, 1..3 of int magicSq(1,1) := %insert # here magicSq(1,2) := %insert # here %and so on.. i don't know wat numbers are u talking about?? |
Author: | enjoy [ Fri Nov 12, 2004 7:38 pm ] |
Post subject: | no one?? |
where are u all ... no one has written anything here... i need some help here guys .... i will be waiting for your replies!! |
Author: | Mr. Glib [ Fri Nov 12, 2004 11:18 pm ] |
Post subject: | |
I think you should check out myob's response...it looks like a good solution to your tic tac toe game. |
Author: | enjoy [ Thu Nov 18, 2004 9:00 pm ] |
Post subject: | yahooooo!!! |
now i am done with the 2 player program (where one user plays against another) thanx for ur help!!!! now i need to make a program that has three levels where a user will play against the computer..... and it is due really soon ... so could u guys give me some ideas on how to do that.... and then the final and the altermate program is a 3D Tic Tac Toe .... but for now coud u guys give me some ideas about the user agains the computer program!!! thanx guys |