Tuesday, January 24, 2006

The Brain of a Virtual Geek

For the geeks in Her Majesty's Hackers, I'm using a simple act/reinforcement cycle: perform an act, get a reward or punishment, be more or less likely to perform an act.

However, there are a few hundred problems with that as stated. Fortunately, I have solved most of them with a simple "exhaustion" system. When an action is performed on an object and a reward is given, the person re-rates them all. But he or she also raises the exhaustion level on all of those things, making him or her less likely to continue.

Exhaustion diminishes over time, but most importantly, it rises linearly. On the other hand, valuation cost is exponential. So, if you gain 5 points of exhaustion and 10 points of valuation, your exhaustion will go up from 9 to 14 but your valuation will only go from 9 to 10. So, on the next sweep, your total current valuation will be -4. That is, valuation minus exhaustion.

Exhaustion drops pretty swiftly as time passes, and there's some multipliers to reflect personality. For example, someone whose social exhaustion multiplier is 0.1 will need to have an exhaustion rating 10 times higher than someone with a multiplier of 1.0 in order to effect the same valuation drop. Also, someone with an 0.1 multiplier will drop exhaustion 10 times faster than someone with a 1.0 multiplier. This means they'll do quite a bit more socializing.

There's a slew of actions, but they are broken into categories. For example, there's a bunch of social actions, from talk to hug to punch, but they are all "social" activities. That is, if someone participates in those, they are under the impression they will be getting a social reward.

Now, I could do that via learning algorithm - each person learns which actions are likely to produce which kinds of rewards. But that would probably take quite a lot of computing, since each person would have to rate each action on each object or person in the game. So, instead, I'm using a hardcoded "likely response" system which allows characters to choose actions suited to the rewards they want.

The "want" for a reward is simply the current valuation of the reward. Which means "valuation minus exhaustion". The character chooses the reward he wants most and looks around for likely candidates. From the list of applicable actions in each candidate, he sees if there are any which would suit his interest. If he finds no local, suitable actions to take, he halves the value. If it is still higher than the other wants, he goes hunting for it.

For example, if he's looking for "respect", that's a social goal, and so he'll look for other people. Upon finding one, he'll determine how much respect he wants and the various social activities to gain respect. For example, winning a game will theoretically gain him a small amount of respect, whereas explaining his recent theory will gain him a larger amount of respect.

If he only wants a small return at the moment, he'll probably invite Bob to play chess. Otherwise, maybe he'll tell Bob about his new theory. Either way, there's an introductory phase where the two (or more) people greet each other and synchronize.

Of course, it might turn out that Bob doesn't want to hear about your boring theory, or doesn't play chess. I do have to keep track of this stuff, because otherwise the simulation falls apart. The "social memory" will weight your chances of doing a particular action with a particular person based on their earlier reactions to your offers... and based on what other people have told you.

If Bob says, "I don't much like chess", when you feel like just plain old socializing, you may tell Susan "You know, Bob doesn't like chess." Then good old Sue will faithfully record a memory telling her not to play chess with Bob. The slant on the commentary will also tell Sue what you think of Bob. What she thinks of you will determine how seriously she takes what you think of Bob.

What you end up with is a rather nice evolving set of activities and friendships and enemyships.

It does tend to stagnate into a "solved" pattern, but with the addition of mad science, random events, and variation in skill, it should remain pretty fresh once everything's working.

There's a few things I'll be adding that aren't existant yet. For example, I want people to be able to make dates, instead of just suddenly going out on one. "Meet you for dinner" or "play chess at lunch" should be perfectly valid. Haven't quite gotten there yet, though.

I would also like to add a "character arc" plot manager. For example, Sue's evolution into a social creature rather than an antisocial creature, or Bob learning bravery. These guides should make the game far more interesting.

Similarly, there should be some level of algorithmic analysis on the conversations of others. For example, if everyone tells you that Bob hates chess, but Bob is constantly playing chess with you, maybe that means Bob has another reason to want to spend time with you. I don't really need this added level of complexity, especially since all my people are intended to be socially inept, but it would be nice for future games.

I'm going to go reprogram the whole thing now. It's not clean enough, yet.

2 Comments:

Blogger Patrick said...

The part about likelyhood of action based on prior evidence really is reminiscent to me of Bayes' theorem, which makes me think that valuations should be measured in floats (though you could do negatives if you program your bayes function to interpret them). Obviously this is a 30 degree turn from what you're thinking of, but wouldn't it be interesting to have a game about hyperrational science geeks use Bayes' theorem as a primary mechanic?

4:59 PM  
Blogger Craig Perko said...

This has a few advantages over a Bayesian system, mostly in clarity and speed. However, there are similarities. :)

5:55 PM  

Post a Comment

<< Home