Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Tic Tac Toe Game Thread

Author
Message
RangerEllis
13
Years of Service
User Offline
Joined: 15th Jan 2011
Location: Terrestrial Productions Current Project:
Posted: 2nd Feb 2011 19:18 Edited at: 12th Feb 2011 04:43
This is where I'm going to ask for help from now on to limit thread quantity. The current problem is I can't fit in the code from DeadTom below into the program for a random computer spot selector.

Also just so you know this code is going to be given out to everyone in the forums so they can mess with it, or learn from it. Thought I might say if it would help to finish this. THANK YOU!

*EDIT*
Attached below is the .exe file of Terrestrial Productions Tic Tac Toe Multiplayer. Everthing is now finished, except we might update the graphics.

Join Terrestrial Productions at http://terrestrialproductions.webs.com to help develop games for the community!

Attachments

Login to view attachments
DeadTomGC
14
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 4th Feb 2011 18:51 Edited at: 4th Feb 2011 23:27
First, to say or put ||(shift \) instead of &&.

About the part where you are having trouble:

Here is a way to lose the loop


Edit:
new code This covers the entire AI's turn the first part are the vars that must be declared


As you can see, this is alot shorter than what you have right now.
What I suggest is make a 3x3 int array(places in the code) in which 0 means empty, 1 means taken by player one, and 2 means taken by the AI.

This allows you to use more loops to check through for three in-a-row.

I'll get a new signature someday.
RangerEllis
13
Years of Service
User Offline
Joined: 15th Jan 2011
Location: Terrestrial Productions Current Project:
Posted: 6th Feb 2011 18:05
thanks for the effort for this, but I am kinda lost on where to put the code and how to implant it. Are you saying that I use those "
ints", and when it comes to the part of code needed to pick a random spot use the bottom portion? Also will it work to detect a spot allready taken by a pre-organized move, because right now if the player goes first the computer picks a spot that has the best chance of winning. Could I use the if (// the code needed for pre-organized move//), and else if (//then use the random one?//)
Thanks!

Join Terrestrial Productions at http://terrestrialproductions.webs.com to help create games that will be given to the community, and posted on web so that people can learn from them, and play them
DeadTomGC
14
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 7th Feb 2011 22:08 Edited at: 8th Feb 2011 00:17
Yes, the bottom part is meant to be-Wait,shouldn't this:
else if ( AA == false &&
AB == false &&
AC == false &&
BA == false &&
BB == false &&
BC == false &&
CA == false &&
CB == false &&
CC == true && CAi == 1 ){
be this:
else if ( AA == false &&
AB == false &&
AC == false &&
BA == false &&
BB == false &&
BC == false &&
CA == false &&
CB == false &&
CC == true && CCi == 1 ){
Anyway, the bottom part is meant to be the replacement for every thing from while ( Turn == false ){ to the end bracket of the while loop

I'll get a new signature someday.
DeadTomGC
14
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 8th Feb 2011 05:55
. Continuing from the last post...
instead of using AA and AB to tell if the spot is taken, you could just use AAi and ABi to do this. Have 0 mean untaken, 1 mean player taken, and 2 mean AI taken. This eliminates the need for AA and AB etc.
Along the same line of thought, have AAi, ABi...CCi be replaced by an array. like "int places[3][3];"
This allows you to loop through the places on the board rather than name them specifically. And it line up with the code I gave you earlier. If you don't transfer you variables over to this sort of format you really can't use all of what I gave you.

The idea behind the array "spots" is to have a list of open places from which the computer can randomly select a spot to occupy.

Every time a spot is taken you should have some code like this:

the first two lines manage the open places. The third claims the place for one of the players. Keep in mind you need to know which row and which colum the spot is in(row and colum numbers range from 0-2). (arrays are indexed from 0 up)

It is hard to explain exactly how the first two lines work, but it is not complicated. Just draw out spots on paper as it starts and see what happens as random spots are taken.

Something to keep in mind, When you make a variable and don't assign a value, it is not automatically anything in particular.
Instead, it is filled with garbage.

I'll get a new signature someday.
RangerEllis
13
Years of Service
User Offline
Joined: 15th Jan 2011
Location: Terrestrial Productions Current Project:
Posted: 8th Feb 2011 14:15 Edited at: 9th Feb 2011 01:03
Ok so heres my whole code



Am I doing what you said to do correctly?

Ok I did NOT do that correctly at all. I don't understand fully how that would work, but
Quote: "wirow=ComputerFirst/3.;
wicolum=ComputerFirst-wirow*3;"

how does that work? I mean if it chose to be "2" and you divide it by three it would place the circle to the left of the grid board. Did you just do that as an example code or what? Also since a human player would go as well how would I work that in? This really confused me.

Join Terrestrial Productions at http://terrestrialproductions.webs.com to help develop games for the community!
DeadTomGC
14
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 11th Feb 2011 05:45
Oh! I did not know you edited.

Ok, in the quote. If you chose 2 then the first line makes wirow=2/3=0. 2/3=0.6666...which gets truncated to 0.
Then the second line is wicolum=2-0*3=2.
This means that the spot with the star is the selected spot.
00* 0
000 1
000 2

012

Quote: "place the circle to the left of the grid board"

Are you saying that the circles do not get drawn in the correct spot? By my math they should be drawn at 200 + 100 * wicolum=200+200=400 (which is correct) and 125 + 100 * wirow=125
which is also correct.

You are not done transforming your code. The way I set up my code was so that you had to get rid of the AAi, ABi, etc and use "places" instead.

This may take some work but none of it is complex. The basic way to transform your code is to replace All AAi with places[0][0] and ABi with places[1][0].

To be continued...

I'll get a new signature someday.
DeadTomGC
14
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 12th Feb 2011 02:03
Continuing.. To use this code for other players just run the same code except determine which spot to take based on user input instead of a random. Also you can probably get rid of the lines in the quote you gave because you will probably already know those.

I'll get a new signature someday.
RangerEllis
13
Years of Service
User Offline
Joined: 15th Jan 2011
Location: Terrestrial Productions Current Project:
Posted: 12th Feb 2011 03:09 Edited at: 12th Feb 2011 04:38
Ahh I see how you're doing it now. And actually no circles were even being drawn. I was getting annoyed so I stopped with the AI and made a seperate .cpp for 2 player tic tac toe! It is almost done and will be posted as an .exe file as soon as possible! If you would like the code you will need to be a member of Terrestrial Productions!

*EDIT*
.Exe file of Tic Tac Toe Multiplayer is available on the first comment.

Join Terrestrial Productions at http://terrestrialproductions.webs.com to help develop games for the community!
RangerEllis
13
Years of Service
User Offline
Joined: 15th Jan 2011
Location: Terrestrial Productions Current Project:
Posted: 12th Feb 2011 03:19 Edited at: 12th Feb 2011 04:34
Uhh but before I do I need to clean up a few problems. In the game when I click an area and not release ( since it's two player ) I can play the whole game with one click. How would I make it so that I couldn't go on another spot until I release?

*EDIT*
Well I figured it out myself so I will post how I did.

Also in your action part of the "if" statement make sure you put "MouseRelease = false;" so that it can reset itself.

Join Terrestrial Productions at http://terrestrialproductions.webs.com to help develop games for the community!
RangerEllis
13
Years of Service
User Offline
Joined: 15th Jan 2011
Location: Terrestrial Productions Current Project:
Posted: 16th Feb 2011 13:21
The game is available in .exe form on the first comment if you guys didn't know.

Join Terrestrial Productions at http://terrestrialproductions.webs.com to help develop games for the community!
RangerEllis
13
Years of Service
User Offline
Joined: 15th Jan 2011
Location: Terrestrial Productions Current Project:
Posted: 26th Feb 2011 01:25
Sorry about the delay of updates school is slowing me down a lot. Not to mention my mom.

Join Terrestrial Productions at http://terrestrialproductions.webs.com to help develop games for the community!

Login to post a reply

Server time is: 2024-10-02 15:26:57
Your offset time is: 2024-10-02 15:26:57