Game Development Reference
In-Depth Information
'Side effect: show what temp we are using
World.SetPointLabel.Text = CStr(World.SetTemps(foundss))
'pass that same value back to the AI.
Return World.SetTemps(foundss)
End Function
This code also knows more than is healthy about how the world imple-
mented the set points, but since that data is directly related to the AI code,
it is not as likely to cause problems. The side effect of setting the text of
the label is intentional. In this project, it helps debugging by showing that
the right set point was selected. In a much broader sense, this is an imp-
ortant part of game AI. As pointed out in Chapter 1, the intelligence must
be made noticeable to the player. In addition to finding ways to make the
AI smarter or less stupid, the AI programmer must always be looking for
ways to make the AI visible to the player.
24. Having gathered data from the world, it is time to upgrade the core AI to
make use of it. We will change the signature to include the mode and then
make the rest of the code mode aware. Here is the new core code:
'This function evaluates input temperatures and mode and gives back a
'response for the furnace as a string
Private Function CoreAI(ByVal currentTemp As Integer, _
ByVal desiredTemp As Integer, _
ByVal mode As CurrentMode) As String
Select Case mode
Case CurrentMode.Heat
'the same exact code as before
If currentTemp < desiredTemp Then
Return ("Heat")
Return ("Ready")
End If
Case CurrentMode.Cool
'note that we flipped the comparison
If currentTemp > desiredTemp Then
Return ("Cool")
Return ("Ready")
End If
Search Nedrilad ::

Custom Search