Use of Utility Functions in Interactive Fiction

11 views
Skip to first unread message

Robert Taylor Fisher

unread,
Apr 20, 1992, 3:29:23 PM4/20/92
to
Early attempts at simulation of characters in Interactive Fiction relied
upon the use of "scripts." Each script was painstakingly written for each
character, taking into account what the player might actions the player might
perform. Take, for instance, Mrs. Robner in Infocom's Deadline. After
opening the door for the player, she would state something, and head off to
eat breakfast. However, nothing the player could do could change her course
of action. Thus, while the script method produced lifelike, believable action,
it did so at the cost of flexibility.

An alternative method relies upon the use of "utility functions," which
are commonly seen in economics and game theory. The basic concept is very
simple. Let x1 and x2 be two choices which a person has available to him. Also
suppose that he prefers x1 to x2. Assign values to x1 and x2 using the utility
function U(x) in such a way that if the person is rational, U(x1) > U(x2).
The actual values assigned are arbitrary so long as they retain the order
of the preferences. This concept is easily extended to any number of options
{xn}.

Usign utility functions, one can design characters with built-in
preferences which will determine that character's actions. To make things
more realistic, one can also make the utility functions dependent upon time
so that characters will tend to be more dynamic. As an easy example, take
the simulation of hunger. If the current time is t and the character last
ate at time to, then we could simulate the character's need for food as
a utility function which is proportional to the amount (t - to). One could
make the function's value inversely proportional to the size of the
character's last meal, c. Thus, the form of the utility function for
acquiring food would be like U(eating)~ 1/c * (t - to). This is just an
arbitrary example -- better forms for the function could probably be
chosen. If one were to compile dozens of these functions, each of which
depends on time, the program would take the character and evaluate
the functions, determining which option has the highest value, and then
enable the character to carry out that action.

The form of the function may also have some conditional dependence. For
instance, suppose we had an option for striking the player. The function may
have a clause reading (if player strikes me) then add X to function. In this
way, the characters would take into account how the player interacts with them,
and react accordingly. Perhaps most excitingly, the characters can also be
allowed to interact among each other using slight alterations to this scheme,
possibly having extremely subtle effects on their interactions with the player.
All that would be necessary would be to to replace appearances of the explicit
(player) with some variable X that would represent a non-player individual.
If we were to consider the utility function for striking X, it would then
read as (if X strikes me). In order to ease programming, eventually it would
be best to incorporate large lists of actions under one heading so that the
game designer would not have to think of all possible choices a player
has. Thus, actions such as "strike, swear, spit" might be placed under the
title of "offend."

Thus, in summary, the scheme for a program using utility functions would
look like

Repeat for all characters...
(Determine action y such that U(y) is larger than that for any other choice.)
(Make character carry out action y.)

Of course, the main problem rests in carrying out the second step, which can
prove to be daunting. However, the utility function method has the incredible
advantage of not having to take into account all possible contigencies, because
it relies only on the evaluation of the utility functions from game step to
game step. It has a certain amount of freedom in this regard, although the
effects will only be noticable in simulation of large systems with many
individuals. A key difficulty lies in the production of speech. Using the
utility function approach would still entail writing up scripts to for
each character response. A more robust method will eventually be needed,
which produces text "on the fly." We note that this system, combined with
another system which generates dialogue text for characters will have the
effect of making the characters more independent of the gamemaker, and
ultimately, more life-like.

Feel free to mail any comments to me at
bo...@arrester.cco.caltech.edu

Robert Fisher

Reply all
Reply to author
Forward
0 new messages