-
Othello game loop
Hi,
I designed a game loop for my othello program. I used a new approach, but i still felt it might contain something illogical. Can i ask you to hava quick look at it and spot out any obvious errors? You know, other ppl tend to see errors more quickly ^.^
Code:
Main game loop
------------------------------------------------------------------------------------
display splash
print board and other visual elements
ask for game mode, single, 2-player or demo-play
if ( mode == 1 )
ask for difficulty
flip coin, decide who moves first, b or w (human player is always black)
while ( gameEnd == false )
display orange new piece
if ( gameMode == 1 || gameMode == 2 )
if no legal moves for currentPlayer
pass
else
get move until a legal move is chosen
make move, flipping pieces
else if ( gameMode == 0 )
if no legal moves for currentPlayer
pass
else
make move using minimax algorithm
change current player
update score
check game ended? If yes gameEnd = true, display scores and winner
when ESC key is pressed, gameEnd = true
ask if start a new game
if yes goto newGame;
end program
-
Looks fine to me. Good luck on the AI, Othello is a little tougher than some of the others to write AI for. Many times the winner of the game is the person who is losing, losing, losing, and then suddenly at the very end takes over the board. Kinda hard to teach a comp that!
-
A little quibble - if the human's black, the human should always go first. AFAIK, black always goes first in Othello.
edit: Other than that, looks good - let me know when it's done (I love that game) :D
-
Ahh!!!! An error i found. In "If game mode is 1 or 2" how would the compiler know if the current player is computer or human? I corrected to the following:
Code:
Main game loop
------------------------------------------------------------------------------------------------------------------------
display splash
print board and other visual elements
ask for game mode, single, 2-player or demo-play
if ( mode == 1 )
ask for difficulty
flip coin, decide who moves first, b or w (human player is always black)
while ( gameEnd == false )
display orange new piece
if ( gameMode == 1 || gameMode == 2 )
if no legal moves for currentPlayer
pass
else
if humanOrComp(currentPlayer) == HUMAN
get move until a legal move is chosen
make move, flipping pieces
else
make move using minimax algorithm
else if ( gameMode == 0 )
if no legal moves for currentPlayer
pass
else
make move using minimax algorithm
change current player
update score
check game ended? If yes gameEnd = true, display scores and winner
when ESC key is pressed, gameEnd = true
ask if start a new game
if yes goto newGame;
end program
My question is is there any way to to remove the duplicate of line "make move using minimax algorithm"?