Othello evaluation function

natchan picture natchan · Sep 8, 2012 · Viewed 12.7k times · Source

I am currently developing a simple AI for othello using min-max and Alpha-beta pruning.

My question is related to the evaluation function for the state of the board.

I am currently looking to evaluate it by counting

1) Disc count

2) No of legal moves

3) Importance of particular positions

So lets say the root node is the initial game state. First action is the the AI's action while the second action is the opponent's action.

                   0    
                  / \           AI's Action
                 1   1
                / \   \         Opponent's action
               2   2   2

At node level 1 do i evaluate the disc count of my AI's chips and the number of legal moves it can make at the point of time after it has completed an action?

At node level 2 do i evaluate the disc count of the opponent's chips and the number of legal moves it can make at the point of time after the opponent has completed an action? Meaning AI move -> Opponent move ==> At this point of time i evaluate the opponent's disc count and the number of legal the opponent can make.

Just want to check if i am on the correct path because it feels strange to count the number of legal moves of a player that has just completed an action.

Thanks and regards, Nat

Answer

PALEN picture PALEN · Sep 9, 2012

When generating games trees, you shouldn't evaluate a node unless it is a leaf node. That is, you generate a tree until a level N (which corresponds to a board with N moves made ahead of the current state of the board) unless you have reached a node which corresponds to an end of game situation. It is only in those nodes when you should evaluate the state of the board game with your evaluation function. That is what the minimax algorithm is about. The only case I know in which you evaluate a node after every player move is in iterative deepening algorithm which seems you are not using.

The evaluation function is responsible for providing a quick assessment of the "score" of a particular position - in other words, which side is winning and by how much. It is also called static evaluation function because it looks only at a specific board configuration. So yes, when you reach level N you can count the possible moves of both the computer and the user and substract them. For example, if the result is positive it would mean that the computer has the advantage, if it is 0 it would mean a tie and it it is negative it will represent a disadvantage situation for the user in terms of mobility. Scoring a node which represents an end of game board configuration is trivial, assign a maximum value if you win and minimum value if you lose.

Mobility is one of the most important features to be considered in the evaluation function of most board games (those in which it is valuable). And to evaluate it, you count the possible moves of each player given a static board configuration no matter whose turn is next. Even if a player recently made a move, you are giving scores to boards in the same level N of the tree when the same player made the last move (therefore, scoring them in the same conditions) and picking of those the one which has the best score.

The features you are considering in your evaluation are very good. Usually, you want to consider material and mobility (which you are) in games in which they are very valuable (though, I don't know if material is always an advantage in Othello, you should know it better as it is the game you are working on) for a winning situation so I guess you are on the correct path.

EDIT: Be careful! In a leaf node the only thing you want to do is assign a particular score to a board configuration. It is in its parent node where that score is returned and compared with the other scores (corresponding to other children). In order to choose which is the best move available for a particular player, do the following: If the parent node corresponds to an opponent's move, then pick the one with the least (min)value. If it is the computer's turn to move, pick the score with the highest (max)value so that it represents the best possible move for this player.