Here's how I figure it out. This is what is called a "recursive" problem, because at each board, the best move depends on which moves are best for the resulting boards that arise when each of the possible moves are played on this one. So this keeps depending on later and later moves, until the last move is played and the game is won or lost. For this reason, I actually start figuring this out by beginning at the last moves of the games on file, and that's easy: the last move of each game is the one that won the game, so it has to be the best. Then I work backwards towards the beginning.
For moves that aren't the last, for each move there is a board which arises when that move is played; let's call it the next board. There are two cases:
Now, knowing which are the winning and losing moves, we consider the current board. If all the moves are losing, the best we can do is choose the losing move that delays the end as long as possible. That's the "best move" when all there are is losing moves. If there are any winning moves, we're going to want to use one of them, and the best of them is the one that wins in the least number of additional moves.
I keep track of how many moves are in the 'best' game of each board, and use the information when figuring which is the best move on the board that comes before.
Of course, nobody actually plays that derivative game, and the real game of hex, played by good players, is very different from it. But it's a start, and that's all I ask.