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.
flowchart code for tic tac toe
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
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
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
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
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.
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.
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement