Original Post
Looks like the last thread kind of wrapped up at the end there, and I want to get some opinions on a kind of new idea related to what was discussed in that post. I don''t know if that has already been done, but I haven''t heard anybody talking about anything quite like this. I haven''t put any of this to practical use yet, I''ve just been thinking about it and discussing it with someone by e-mail.
The idea is a system for NPC behavior, probably most compatable with an adventure game or RPG. It''s pretty much like the "needs" stuff discussed in the previous thread, only more dynamic and complex. The system is based on something I guess you could call Priority objects. A Priority data structure would include information about a state of being, possible actions related to that state, and some kind of numerical expression that represents the relative importance of this Priority. Each NPC would have a list of priorities, starting with a "default" priority that gets carried out when nothing else is happening (eg. "whittle wood"). Most NPC''s will always have a self-preservation priority that will shoot to the top of the list in certain circumstances. In a given situation the priority list will be traversed from top (most important) to bottom, and each priority will have a chance to determine the actions of the NPC. Each priority will also have a chance to modify its own importance based on the situation. This idea can also use the scheduling ideas from the last thread to introduce new priorities to the queue.
Here''s an example, using completely arbitrary numbers where necessary. Our NPC is Bob. It''s about 9pm and Bob is sitting in a pub having a drink. We go through the priority queue and the first time we go through the list and reassign priorities. The first priority is "get drunk" with a value of 15. Well, he''s already drunk and the more he drinks the less he cares about getting drunk. This priority has been decreasing for an hour or two and now it just removes itself from the list. This task is basically complete. Next in the list is "go home", which becomes more important the later it gets, so it increases its importance to 20. Bob''s personal schedule inserts a "sleep" priority in the queue at 9pm after he''s been awake for 16 hours (or something), and since he had a busy day and got drunk this priority will start at 10. After going through the list and assessing all of the values, now we start at the top again and act on the priorities. The top priority now is "go home", so we call the only associated action and Bob starts walking home. The action associated with "go home" will also look for faster modes of transportation, evaluating how much money he has and possibly checking against the value of an "actionless" priority such as "save money".
There are obvious problems here and tricky situations to work around. Numeric values for the priorities will have to be carefully calculated. In the example if Bob is far enough away from his house then the calculations should have the priority of sleep overtake the "go home" priority, so Bob camps out or something. The self-incrementing and decrementing priorities can make for some very realistic behavior. For instance, the value of the sleep priority becomes higher and higher until you sleep, and while you''re sleeping it will decrease. In the morning the schedule (or alarm clock or something) will insert a "get up and go to work" priority of some sort, with a certain value. If you waited long enough to sleep then that priority will still be greater than the "get up" priority and the NPC won''t get up. Sooner or later though, the increasing "get up" priority will overtake the "sleep" priority and the NPC will get up. Priorities can be used to describe just about any possible situation and related actions. In combat priorities would include "kill enemy", "preserve self", "protect friends", all with changing values based on the situation (your health, the enemy''s might, your friends'' health).
So, any comments, thoughts, suggestions?