Game Development Reference
In-Depth Information
Public Class Larry
Inherits Person
'Larry is shooting for the big time but can't afford to lose
Public Overrides Function Evaluate(ByVal Task As Job, _
ByVal Cash As Double) As Double
Return Task.PSuccess * Task.Gain - (1 - Task.PSuccess) * Task.Loss
End Function
End Class
Public Class Barry
Inherits Person
'Barry is bolder than Eddy but needs surer things than Larry
Public Overrides Function Evaluate(ByVal Task As Job, _
ByVal Cash As Double) As Double
Return Task.PSuccess * Task.PSuccess * Task.Gain - (1 - Task.PSuccess) *
(1 - Task.PSuccess) * Task.Loss
End Function
End Class
It may be amazing that we can model people in just one equation of four
variables. We are nearly ready to see how they respond. To do that, we must
finish the simulation.
Finishing the Code
Return to the code for MainForm. We are going to add the simulation code here.
The simulation will start out a person with 10 days' wages. It will then loop through
1,000 days. Each day it will see if the person wants to change jobs. If he or she does,
it will give the output from the prior job. Once a job is known, it will be evaluated
for success or failure, and living expenses will be deducted. At the very end, it will
show us the result of the last job held. Add the following code to the class:
Private Sub RunSim(ByVal name As String, ByVal Dude As Person)
ThoughtsTextBox.Clear()
'Start with 10 days' wages.
Dim cash As Double = 10.0
'Fake out the curJob to get started.
Dim curJobName As String = "Just starting out"
Dim curJob As Job = Nothing
'Working variables:
Dim wages As Double
Dim expense As Double
 
 
Search Nedrilad ::




Custom Search