Game Development Reference
In-Depth Information
Figure 2.2
Thermostat project, ready for code.
15. We will start with the core AI routine. Designing it first will show us
what inputs the AI needs from the world and what outputs it will want to
implement. Add the following code to the AI.vb file between the Module AI
and End Module lines:
'This function evaluates world conditions and gives back a
' response for the furnace as a string
Private Function CoreAI(ByVal currentTemp As Integer, _
ByVal desiredTemp As Integer) As String
If currentTemp < desiredTemp Then
Return ("Heat")
Return ("Off")
End If
End Function
This is only the core code. We need additional code to extract the inputs
from the world and to implement the output. The function is marked
private because we expect it to be called by other AI code that will provide
the translations. Note that comment lines in VB start with a single quote
Search Nedrilad ::

Custom Search