Sign in to follow this  
Koolchamp

[C++] Checking if round was a Tie...need help [RESOLVED]

Recommended Posts

Hello to whoever reads this, :) Im creating a text TicTacToe Game. Im at the point where I check whether 3 In-a-Row has been made or if the round ended up being a Tie. I've got the checking for 3-I-A-R done and it works. Im having problems with finding if the round was a Tie. My problem is, I don't know where to start...how to start. My game board is a multi-dimensional array. I check the 3IAR part with a lot of if statements like this: if(game_board[0][0] == 'X' && game_board[0][1] == 'X' && game_board[0][2] == 'X' { player2_wins = true; } etc..... Thing is, I don't think I can do this for checking if there is a Tie. If anyone has any suggestions on how I would go about checking for a Tie, I would really appriciate a respone. Thank you. [Edited by - Koolchamp on May 19, 2006 3:54:07 PM]

Share this post


Link to post
Share on other sites
Well when you check for a win, you need to check whether any of the corresponding positions are equal:

123
456
798
147
258
369
159
357

If any of those triplets are the same piece then you have a winner. Otherwise it is a tie.

To code it, i would iterate through an array that stores these 8 lots of 3 numbers in chunks of 3.

Hope that helps,

Dave

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this