For game AI like chess and reversi, the essential AI logic is minmax, what is your best move that results in your opponents worst move? For reversi, this is simple to calculate, out of all possible moves how many pieces will you win/lose. The most basic approach would be one level deep, pseudocode:
Code:
array moves = getListOfPossibleMoves();
int bestMoveIndex = 0;
int bestMoveValue = 0;
for(int i = 0; i<moves.length; i++){
int moveValue = getMoveValue(moves[i]);
if(moveValue > bestMoveValue)
bestMoveIndex = i;
}
makeMove(moves[bestMoveIndex]);
To make it a bit more advanced you would look at later levels. So for each move the moveValue would be the number of pieces you win minus the most number of pieces your opponent could win if you make that move. Be cautious, unless you use an advanced search algorithm like A*, alpha-beta with pruning, etc. going beyond 3-4 levels would likely be very slow. Maybe not for reversi, but definitely for chess. If you have multiple difficulty levels, each level could correspond to a different amount of moves that the computer will look ahead.