Google Groupes n'accepte plus les nouveaux posts ni abonnements Usenet. Les contenus de l'historique resteront visibles.

[INFORM] Very, very complex NPC code

19 vues
Accéder directement au premier message non lu

BWilliams

non lue,
21 avr. 1999, 03:00:0021/04/1999
à
Can anyone recommend a game with public code that I could look at to see an
example of a very, very complex NPC or NPC class to get some ideas from?
I'm thinking of an NPC complex enough to feel like a fellow player, with so
wide a range of responses that it really would truly function as a
companion. I would like to see what someone else has done to build such a
character, so that I can learn from the work of others as I build a game
with a very character centered focus.

Any suggestions?

Jennifer Earl

non lue,
21 avr. 1999, 03:00:0021/04/1999
à
Gareth Rees' excellent Christminster has great NPCs, most notably Edward.

The game file is at
ftp://ftp.gmd.de/if-archive/games/zcode/mister.z5
(or the same place in the if-archive mirror of your choice)

The source is in the if-archive at:
ftp://ftp.gmd.de/if-archive/games/source/inform/minster.tar.gz
(ditto)

Keep your eyes open, though, I think Inform has changed somewhat since
Christminster was released.

Thanks, Gareth, for making the source available!

--
Good? Bad? Indifferent. Jennifer Earl
Disgruntellectuals. jaearl @ earthlink.net

----------
In article <7fln7o$q6a$1...@juliana.sprynet.com>, "BWilliams"

Jim Aikin

non lue,
21 avr. 1999, 03:00:0021/04/1999
à
BWilliams wrote:
>
> Can anyone recommend a game with public code that I could look at to see an
> example of a very, very complex NPC or NPC class to get some ideas from?
> I'm thinking of an NPC complex enough to feel like a fellow player, with so
> wide a range of responses that it really would truly function as a
> companion. I would like to see what someone else has done to build such a
> character, so that I can learn from the work of others as I build a game
> with a very character centered focus.
>
> Any suggestions?

I can't suggest any source code, but my (still very limited) experience
suggests that a useful way to start is to imagine what states you want
the NPC to be in during the course of the game, and then give it
properties (which can be coded as simple switches) corresponding to each
state:

with cheerful 0, unconscious 0, angry 0, covered_with_fleas 1, ...

The player would usually need to execute specific actions to switch one
of the NPC's state variables, although some might switch in response to
the time of day (if your game has the passage of time) or whatever. Your
daemon, life, and orders code can easily test:

if (self.cheerful) {self.action_1(); "blah blah blah...";}
!else
self.action_2();
"blah blah blah...";

The tricky bit is what happens when the NPC is cheerful but also angry
and unconscious. What I'd do is make sure that any code that says, for
example,

NPC.cheerful = 1;

also says

NPC.angry = 0;

...except where you WANT dual states to coexist.

The limiting factor in coding such a character is the combinatorial
explosion, a term one of my REAL programmer friends mentioned to me one
time. What it means is this: With 2 state properties, your NPC has a
total of four possible states: A==0 && B==0, A==0 && B==1, A==1 && B==0,
and A==1 && B==1. When you add a 3rd state property, the number of
possible states expands to 8. With 4 state properties, the NPC can be in
16 different states, and so on. And God help you if you want the angry
property to have a value between 0 and 5! It quickly becomes more
trouble than it's worth to try to keep track of all the possibilities.

This is why NPCs in IF are usually so wooden. Have fun....

--Jim Aikin

*****************************************
"Is that a mouse in your hand, or are you
glad to see me?" --Mae West
*****************************************

cody sandifer

non lue,
22 avr. 1999, 03:00:0022/04/1999
à
Hi there. This is slightly off-topic, but I thought that I'd chime in anyway.

When I coded up Maurice for Zero Sum Game (in TADS, not inform), much of
Maurice's code was housed outside of the "maurice" object. As a
follower/companion, his code (i.e., funny comments or whatever) popped up
when:

the pc entered or left rooms
the pc performed countless actions on people and objects
the pc quit the game
etc.

In other words, just as much of Maurice's code was assigned to the room or
scenery objects as to the "maurice" object. Just something to keep in
mind -- although I don't know enough about inform to know if this comment
is relevant to the programming of inform NPCs.

Good luck,

cody

0 nouveau message