User:Hickman/Othello

From MCIS Wiki

Jump to: navigation, search

Contents

Othello

Purpose of the Project

Reversi and Othello are names for a strategic board game which involves play by two parties on an eight-by-eight square grid with pieces that have two distinct sides. Pieces typically appear coin-like, but with a light and a dark face, each side representing one player. The object of the game is to make your pieces constitute a majority of the pieces on the board at the end of the game, by turning over as many of your opponent's pieces as you can.

Extension

No extension required

Interesting Code

public double alphaBeta(Board board, int depth, double alpha, double beta) {

       double temp;
       if(board.myColor == Piece.White) temp = alpha;
       else temp = beta;  
       if(depth == 0 || b.gameOver) {
           return b.heuristic();   
       } 
       else {
           for(Board nextMove : board.moves()) {
           if(board.myColor == Piece.White) 
               alpha = Math.max(alpha,alphaBeta(nextMove,depth-1,alpha,beta));
           else
               beta = Math.min(beta,alphaBeta(nextMove, depth-1,alpha,beta));                
           }
           if(alpha >= beta) {  
               return alpha;
           }
       }
       return alpha;
   }

Had trouble figuring out how to write this at first

Tip

Ask questions and use the wiki

Hardest Part

Coming up with a successful heuristic that is not based off of black and white counts

Personal tools