/*
board is semi-played
my move.
i generate all possible plays
for each play, I do a global eval of the opponents potential
responses.
I chose the play which maximises MyScore - OppScore(ConfLevel)
With ConfLevel at 100%, it is identical to minimax. I.e. the best
score the opponent can make.
With ConfLevel at say 90%, we take the best score that the opponent
might make with 90% of his possible moves, ignoring the best 10%.
This still gives us a significant advantage.
With ConfLevel at 0%, this is equivalent to just picking the highest
scoring move at each play without considering the opponent at all.
So what does a confidence level of 50% mean? Does it mean that we
average out no better or worse in the long term than the opponent?
NO! It means that for 50% of our plays, we have the guarantee that
if we picked a move which put us ahead, we *will* be ahead;
but for the other 50% of our plays, it's random whether we're
ahead or not.
Conclusion; 0% means 0% advantage, 50% means 50% advantage and 100%
means 100% advantage.
(Of course, there may not be a move that guarantees to put us
ahead, but in that case we're still using the code to minimise
our losses)
I'm glad I've straightened out my thoughts on this, I was starting
to get confused. I originally had thought that the 50% level was
the "no difference" level...
*/
int minimax(int ComputerScore, int OpponentsScore,
int human_player, int plyleft,
int confidence_level, GAMESTATE *game)
if (human_player) {
if (plyleft-- == 0) return(ComputerScore-OpponentsScore);
/* Our turn again */
/* Evaluate all possible plays. Recurse to Opponent */
} else {
if (plyleft-- == 0) return(OpponentsScore-ComputerScore);
/* Opponents turn - do a static evaluation, find the highest
most probable score given the confidence level, and recurse
back to human on next level */
}
}