Game Development Reference
In-Depth Information
number describing how much the person likes a given job. Now we need specific
people. After the End Class line, add the following code:
'Real games would not subclass these, but it makes it simpler to understand
Public Class Eddy
Inherits Person
'Eddy values a sure thing and balances loss against doubly adjusted gain.
Public Overrides Function Evaluate(ByVal Task As Job, _
ByVal Cash As Double) As Double
Return Task.PSuccess * Task.PSuccess * Task.Gain - _
(1 - Task.PSuccess) * Task.Loss
End Function
End Class
Public Class Gary
Inherits Person
'Gary is all about the upside potential
Public Overrides Function Evaluate(ByVal Task As Job, _
ByVal Cash As Double) As Double
Return Task.Gain
End Function
End Class
Public Class Mike
Inherits Person
'Mike is a miser
Public Overrides Function Evaluate(ByVal Task As Job, _
ByVal Cash As Double) As Double
Return -Task.Cost
End Function
End Class
Public Class Carl
Inherits Person
'Carl wants easy money and doesn't care about risks
Public Overrides Function Evaluate(ByVal Task As Job, _
ByVal Cash As Double) As Double
Return Task.PSuccess * Task.Gain
End Function
End Class
Search Nedrilad ::




Custom Search