Advertisement

game help

Started by February 23, 2001 11:00 PM
2 comments, last by TriWolf 23 years, 11 months ago
I'm making a tick-tac-toe game it runs but can't determine a winner. I know of only one way to determine one and that is through if statements but that would required a large amount of them which would be confusing and ineffective. If you think you can help I'll send you the source code. Email me at Trussell86@hotmail.com Edited by - TriWolf on February 23, 2001 12:00:51 AM
Timothy "TriWolf" Russell
last year i made a 3d 4x4x4 tictactoe game for my final project. and it was funny when another group showed up w/ a 3x3 2d tictactoe that had manually coded moves/wins.

anyways, i''m assuming ur using a 3x3 matrix.
here''s how i would do it:
1. pick a square
2. pick a direction(8 directions)
3. check if that dir is in bounds
4. if it is, go in that direction again
5. if it''s still in bounds, that player wins
if now, go back to step 1.

there''s 9 squares to choose from from step 1. i would choose just a L shape from one of the corners
XXX
Xxx
Xxx
if u follow steps 2-5 for those CAPPED X''s, then there''s no other possibility of winning.

here''s my game if u want to c it:
http://thuned.dhs.org/programming/tttg.exe
ai''s kinda buggy when we submitted it; we never bothered to fix it after we turned it in tho.

thuned



life is unfair, take advantage of it.
UNMB2 - if the link doesn''t work, try clicking it
life is unfair, take advantage of it.UNMB2 - if the link doesn't work, try clicking it :)
Advertisement
Theres only 8 possible combinations of winning for each player, so only 16 if statements altogether. Since it''s just a simple tic tac toe you have plenty of time to spend doing the if statements. Not only that, but you don''t even have to check every frame; just when a square''s data is changed.
Thanks all I did it a bit differntly when I started over and it''s much better. Of course there no ai yet but the if statements do looks a bit better than before .

Timothy "TriWolf" Russell
Timothy "TriWolf" Russell

This topic is closed to new replies.

Advertisement