Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


flowchart code for tic tac toe


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 14 November 2012 - 06:52 PM

here is a pseudo flow chart for a tic tac toe game. I just want to know if I have left anything out or have too much.

Start
enter player X
mark X spot
generate random player O
check board for blank space
mark O spot
check for winner
state winner
end

I am going back to the beginning to get a better perspective on my game.

Sponsor:

#2 Khatharr   Crossbones+   -  Reputation: 3036

Like
0Likes
Like

Posted 14 November 2012 - 07:04 PM

Could you be more explicit in your descriptions of each step?

I would probably state it more along the lines of:

-Generate Player X
-Generate Player O
-Begin Match loop
--Player places symbol
--Break if win/draw
--Proceed to next Player
-If win process win
-If draw process draw

Edited by Khatharr, 14 November 2012 - 07:04 PM.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

#3 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 14 November 2012 - 07:16 PM

ok
start game
draw board
get player X position from keyboard
mark X spot on board
generate random value for player O
check player X and player O positions
if they are the same regenerate player O
if they are different mark O on board
check board for winner
if three X's or O's in row are on board then state winner
end game




#4 Khatharr   Crossbones+   -  Reputation: 3036

Like
0Likes
Like

Posted 15 November 2012 - 04:54 AM

You need to check for wins after either player's turn, not just O.
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

#5 stoneyrich   Members   -  Reputation: 143

Like
0Likes
Like

Posted 15 November 2012 - 09:18 AM

you could also look at it from this angle. any action to the board as input there must be a corresponding output.

input >
player x,o makes a move
board :
response to player input
display changes to board
output >
check for winner , losers or draw

This in a game loop can give a fair idea.

Edited by stoneyrich, 15 November 2012 - 09:19 AM.


#6 BaneTrapper   Members   -  Reputation: 1244

Like
0Likes
Like

Posted 15 November 2012 - 10:53 AM

Id do it this way

Load all variables
loop that will restart all variables needed for match and check if (Player or AI has 3 wins) if they do, give them victory or defeat hint and probably exit or if you have main menu return to it.
(Match start) loop until condition is met ("3 in row/column..." or "table is full")
if condition is met, add score to winner. Give other player first turn this time and break out of this loop
else Who's turn is it to play
If players wait for input and handle it
if AI generate a move
Display everything

Edited by BaneTrapper, 15 November 2012 - 10:54 AM.

Current projects:
The Wanderer, 2d turn based rpg style game

www.gamedev.net/topic/641117-check-up-the-wanderer/





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS