Be a Supporter!

(c++) Need Help With Tic Tac Toe

  • 446 Views
  • 3 Replies
New Topic Respond to this Topic
Cold-HawK
Cold-HawK
  • Member since: Sep. 11, 2005
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
(c++) Need Help With Tic Tac Toe 2005-12-11 19:21:39 Reply

I'm quite new to C++ and so I've started a Tic Tac Toe game. It has went good so far but now I am stuck with making a code that checks when you've won.

http://hstuart.dk/pa..87-80f7-1e9b4121f8ac

that's what I've made so far.

Ravens-Grin
Ravens-Grin
  • Member since: Jun. 3, 2003
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to (c++) Need Help With Tic Tac Toe 2005-12-11 22:16:32 Reply

Make another function that tests whether someone has won or not and add it to the game loop. Simple as that. It's just going to be a couple of if/then statements.

Cold-HawK
Cold-HawK
  • Member since: Sep. 11, 2005
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Response to (c++) Need Help With Tic Tac Toe 2005-12-12 01:37:55 Reply

At 12/11/05 10:16 PM, Ravens_Grin wrote: Make another function that tests whether someone has won or not and add it to the game loop. Simple as that. It's just going to be a couple of if/then statements.

Yeah, that's a way to do it but aren't there practical ways of doing this?

lolomfgisuck
lolomfgisuck
  • Member since: Jul. 1, 2003
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Response to (c++) Need Help With Tic Tac Toe 2005-12-12 17:11:52 Reply

Everytime you put a peice on the board, check to see if there are two more in any other squares that would make a win.

So if you put an X in the top left, see if there is an X in both the top-mid and top-right. If so, win. Also check to see if there is an X in the left-middle and left-bottom. If So. Win. Check to see if there is an Xin the middle-middle, or bottom-left. if So, win. If not. Keep playing. That is, if there is still an open slot, if there isn't, it's a tie.


John Rambo is my hero

BBS Signature