Game Development Reference
In-Depth Information
'equally bad.
If TheirMove.GameRank <= 1 Then
'Debug.WriteLine(depth.ToString & _
' " HoundsLookahead found a losing move.")
Return TheirMove
End If
'We are still in the game.
'I am looking ahead, I give back results from the future.
Return Hounds2(TheirMove, depth + 1, False)
End Function
The code starts with the expected ways to abort the look-ahead. Depth is
limited to 6 instead of 5, since earlier versions of the code had trouble with 5.
Since a fox victory is a very important condition in determining the quality of a
prior move, the extra depth keeps the hounds out of trouble. The look-ahead
expects that the move it is evaluating still involves a broken line (or Hounds2()
would not have called). Unlike the fox with its shortest path, the hounds get no
other guidance on intermediate moves when reforming the line, so it simply
asks for the result of the hounds' next move now that the look-ahead knows
what the fox will do with the current move. Eventually, one of those future
moves will reform the line.
Run the code in the debugger. Click on the Fox and the Hounds buttons in turn,
starting with the Fox button. Watch the debugging output carefully in the output
window. The hounds' AI should play a perfect game against any opponent. If the
human intervenes, the fox can win. One way to do this is to make the hounds
move three times in a row with no fox moves between.
Chapter Summary
If the computational complexity can be managed, look-ahead provides real
''smarts'' to the game AI. It can be easily toned down for less of a challenge to the
player. There are certainly some challenges for the programmer, but pruning and
heuristics help mitigate them. Possibly the hardest task for the programmer is
coming up with an evaluation function that works reliably. The nuances to
an evaluation function need careful examination. If nothing else, look-ahead
provides a concrete method for fighting Artificial Stupidity.
Search Nedrilad ::

Custom Search