Thread: Othello game loop

  1. #1
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020

    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

  2. #2
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    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!

  3. #3
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    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)

  4. #4
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    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"?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Open Source / Semi Open source game idea. Help needed
    By CaptainPatent in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 05-16-2007, 10:44 AM
  2. 2D RPG Online Game Project. 30% Complete. To be released and marketed.
    By drallstars in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 10-28-2006, 12:48 AM
  3. Personal Program that is making me go wtf?
    By Submeg in forum C Programming
    Replies: 20
    Last Post: 06-27-2006, 12:13 AM
  4. game loop
    By X PaYnE X in forum Windows Programming
    Replies: 6
    Last Post: 02-15-2005, 01:33 PM
  5. for loop or while loop
    By slamit93 in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2002, 04:13 AM