Game Development Reference

In-Depth Information

We get a great deal of mileage out of single equations of only a few variables. The

code and the numbers are simple. We even get sensible unexpected behaviors out

of the system.

There are clear ways to extend the simulation. Because each person is imple-

mented as a class, we can replace the single equation with as much code as

required as long as the evaluate function eventually returns sensible numbers.

There could be more than one equation; there could even be a small finite state

machine in there. A simpler extension would be to use the cash value directly,

the number of days in job, and the day number of the simulation. The days in job

number could feed wanderlust or a feeling of comfortable familiarity. The day

number of the simulation could be used as a proxy for age, perhaps to adjust

tolerance for risk as the person gets older.

With just a few carefully selected numbers and some finely crafted equations, you

can use probability to create surprisingly realistic behaviors for game AI. Getting

the numbers and equations appears deceptively easy. Tuning them is far harder.

Answers are in the appendix.

1. What are three ways to get odds for a game?

2. What are the drawbacks to these methods?

1. Add more occupations and people. Try to fit the new people to the new jobs

without changing how existing people act.

2. Change the equations to include the turn number. Make some of the people

tolerate less risk as time goes by.

3. Change the
Jobs
class so that the
Gain
and
Loss
member functions take cash

as a parameter. Create a retirement subclass and override those member

functions. Treat the
myGain
and
myLoss
values as a percentage to apply to

cash to give the values for
Gain
and
Loss
.