Aller au contenu

Photo

Advancing the state of commoner AI


  • Veuillez vous connecter pour répondre
72 réponses à ce sujet

#1
kamal_

kamal_
  • Members
  • 5 240 messages
By default the random nameless commoner or merchant does nothing. If you give them some stock variables they behave a little better, aging a few animations every once in a while or wandering around a bit. Uncle FB's control scripts help, you can give them schedules and direct them to waypoints and such. But even that is currently rather limited as it is low on variability. I'm hoping to fix all that. Adding both time and location variability and generally making the behavior of the random commoner both more advanced and easier for a builder to implement.

So I wanted to ask what kinds of things would people be interested in seeing out of commoner behavior?

#2
BartjeD

BartjeD
  • Members
  • 249 messages
Small talk ("animated" not strings), buying things, labour, sitting for drinks, child games are things I'd like to see.

Modifié par BartjeD, 29 juin 2011 - 02:56 .


#3
kamal_

kamal_
  • Members
  • 5 240 messages
Iirc the default ambient anims variable does small talk and shopping. What kinds of games? hide and seek is already in Uncle FB's. What kind of jobs? soldier training is already in there, but soldiers aren't really default commoners.

#4
BartjeD

BartjeD
  • Members
  • 249 messages
Does the small talk ambience seek people to talk to and go talk to them? I never noticed that. Same for shopping btw. (That's what I'd love to see - I'll go check if it already does that)

Hide and seek is already there but things like Simon Says or Tag would be neat to see and add variety.

Jobs are difficult in NWN especially since you have to account for the placeables and surroundings. I'd think of chores such as cleaning up things, keeping it tidy, repairing damaged doors and placeables. Taking out the garbadge is another one that would be funny :)

Modifié par BartjeD, 29 juin 2011 - 03:34 .


#5
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Woodcutting, getting water from a well, cleaning clothes, feeding chickens, working in a field, gatheing nuts and berries, peeing in a corner, fistfights, fishing, cooking, driving cattle/livestock, feeding cattle/livestock, peeing on cattle/livestock... maybe not....

#6
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
The ambient system I put together for the Danaan Unvanquished makes it easy to play different sets of animations at different places at different times, plus more complicated things like weeding a garden/crop row, mingling in a crowd, sweeping, chasing/fleeing, and grazing. The code is pretty simple, what we really need are just more animations, for things like micturition, solicitation, and dissipation.

#7
kamal_

kamal_
  • Members
  • 5 240 messages
Things that require group dynamics are too difficult/impossible. They could be done, but only by someone better than I. Setting up individual or two person required behaviors are in my realm. Bartender/maid can be done, to use an example that already exists, but a game of Red Rover couldn't, since that requires multiple npcs to form two lines facing each other. Similarly, npcs listening to a bard is doable since it's a series of one to one interactions, the npcs interact with a bard, not each other and the bard. A group of people carrying out an individual action (digging for instance, where you only need a minimum of one digger) is doable.

The childrens game Ding dong ditch/knock knock Ginger would be doable, since it requires only a single npc and some doors/waypoints. Soccer would be out, too many npcs interacting with each other as a group.

Uncle FB helpfully provides a number of common cases, hide and seek, bartender/maid etc. I should just be able to use his templates to predefine more activities and build in variability.

#8
The Fred

The Fred
  • Members
  • 2 516 messages
This is something on my to-do list as well, but I haven't even begun building populated areas like towns yet. I do have a nice system on the go where NPCs will go to their rooms at night-time, close the door and go to sleep (though they have no sleeping animation...). I'm using this for the academy-like Iron Circle, but it could be used for inns etc. The other stuff is still off on the horizon yet.

It might be worth looking at some of the HotU scripts. There are a lot of ambient scripts (I think prefixed "x2_am_") for doing stuff like waitressing already. I've never tried them so I don't know if/how well they work, and one or two may not work in NWN2, but it seems like there might be a whole load of stuff one could use without having to re-write it all from scratch.

Tig/tag would be pretty doable (I think they actually had it in the NWN1 OC somewhere) and you probably could do football, at least medieval-style football where there's no off-side, etc, though it would take a little more work (a variable for the team, two goal waypoints or triggers, then it's just one-on-one between each player and the player with the ball) and you wouldn't be able to see the ball anyway unless you made some sort of vfx for it.

On the streets, a lot of peasants can just be walking about, because most people you see on a street are just going somewhere indeterminate anyway (recall, if you've ever seen it, The Trueman Show, where the motorist, cyclist and pedestrian just keep walking around his house), but interiors and features like inns and taverns, shops, and perhaps temples, could use a bit of something to bring them to life.

#9
kamal_

kamal_
  • Members
  • 5 240 messages
Inns have the inn wp from the toolset to handle them. Bartender/maid are done already. Blacksmith has been done. Hide and seek is done. Shopping and point of interest are in the toolset (in fact I had a Pavarotti like bard accumulate 40-50 commoners walking around who stopped and watched his performance because of this.)

I'll have to look at lugiads work, no point reinventing the wheel if he's done a lot of this. No longer have nwn1, so maybe someone could dig up those scripts.

#10
Shaughn78

Shaughn78
  • Members
  • 637 messages
For kids games Little Baron made a ball visual effect and scripted a game of catch.
http://nwvault.ign.c...l.Detail&id=297
It uses a custom spell so you will need a modified spell.2da

#11
PJ156

PJ156
  • Members
  • 2 982 messages
I have looked a blending some scripts with FB but it did not work. Mostly because they are looking for thier waypoints on the heatbeat script. Thus for my spy in The Last days of the Raven I wanted her to always be in the hallway in the inn but to walk away fromt he PC whenever they approached. In the end I had to drop the FB scripts on her and stick with something simpler.

I like the sound of your proposal to use several systems, You can draw the best from each to give a lively ambience to the city.

If I were to add more I would like, in additon to many of the above, to see fishing, kissing, sawing I would very much like  preist who blessed people, also I would love to see your street entertainer working. 

The streets of Crimmor are calling me :)

PJ

#12
Arkalezth

Arkalezth
  • Members
  • 3 188 messages
Events? Like theatre (either in a building or in the street) priests talking in the church (I don't know the English name for that), etc. Also, kids going to school if there's one in town, merchants coming from other villages, guards actually doing more than just patrolling or standing next to doors...

Men negotiating with prostitutes? People doing or playing some kind of medieval sport? Bar fights?

#13
kamal_

kamal_
  • Members
  • 5 240 messages
Adding in time randomization to Uncle FB's scripts looks like it proved to be a matter of adding one small script and changing a single function in his include script. I've asked someone that has an already working commoner schedule based on Uncle FB to test, as it's virtually a drop in replacement (in fact you could use it as an override).

I'm adding the ability to set schedules to the minute instead of hour, and have each of the six time periods in Uncle FB's system both start at a random time offset from the defined base time, and optionally last a random amount of time instead of exactly x hours.

#14
kamal_

kamal_
  • Members
  • 5 240 messages
Uncle FB includes the following

//sleeping midnight behavior for beds
//sleeping midnight behavior for benches etc...
//sleeping behavior for beds
//sleeping behavior for benches etc...
//Agreeable conversation behavior
//Angry conversation behavior
//Sad conversation behavior
//Standard Cook Behavior
//Multiple location cooking behavior
//Standard Dancing Female Behavior
//Standard Dancing Male Behavior
//Standard drumming behavior for NPC
//Standard flute behavior for NPC
//Standard forge behavior for NPC
//Multiple location forge behavior
//Standard guitar behavior for NPC
//Standard woodsman behavior for NPC
//Standard meditate behavior for NPC
//Standard stand post behavior for NPC
//Standard reading (sitting) behavior for NPC
//standard sitting behavior (no eating)       
//Standard dinner behavior (sitting)
//Standing behavior (chat, laugh, etc...)
//Training routine for armed combatants
//cheering and clapping behavior
//Trainer Pacing behavior
//Standard WWP behavior
// standard thief behavior
//Thief behavior where the thief actually steals
//Assassin behavior where the Assassin actually kills
//standard hiding behavior no wp required
//standard seeking behavior no wp required
//multi location merchant behavior
//multiple locatin worker behavior (moving bottles)
//kneel and talk animation
//raking animation
//NPC will activate/deactivate light objects
//standard barmaid working with bartender
//standard bartender working with barmaid


Lugaid helpfully defined lots of common actions to use with Dana'an.

//Moves to given post
//For combat, returns to post when not in combat
//wanders aimlessly in area with post sPostTag
//wanders aimlessly in area with post sPostTag, stops to sweep/rake occaisonally
//weeding: used for gnomes in rice paddies in Danaan unvanquished
//for cows, wanders close to sPost, grazes using DRINK animation
//sleeps near sTag
//Sits at Target, Fidgets
//Stands at Target
//Stands at Target
//Plays animation at Post, w/ facing
//runs to post, starts shoveling.  Used for sappers laying mines   
//Plays various listening animations facing target
//Plays Custom animation at Post, w/ facing
//Attacks sTarget on Post w/ranged weapon
//Attacks sPostTag
//Plays taunt animation   
//Plays flute animation, creature must have a flute
//Plays Guitar animation   
//Plays Drum animation   
//Sits on the ground
//Plays Cooking animations   
//Stands and messes with stuff on table   
//Stands and does heavy-labour stuff   
//Stands and looks around   
//Stands and worships   
//Stands and uses social animations
//Like talk, but for instructors, leaders, overseers
//Plays bardsong animation   
//Plays clapping animation   
//Plays dancing animation   
//Plays slowed dancing animation   
//Plays shoveling animation   
//Plays drinking animation   
//Plays reading animation   
//Plays Cower animation   
//moves from one random creature to another, good for barmaids, townwalkers, etc.
//moves from one random waypoint to another, designed for bats
//Chases from nearest object with sPostTag
//Follows at a walk nearest object with sPostTag
//Refugees moving en mass in one direction.


There is some duplication, but I will probably include both versions to give people the choice. Between the two, it looks like most common things are going to be in there.

Here are the suggestions that are not already in the list: Woodcutting, getting water from a well, cleaning clothes, feeding chickens, driving cattle/livestock, feeding cattle/livestock, fishing, Simon Says or Tag, kissing, sawing, priest blessing the congregation, kids going to school if there's one in town, Men negotiating with prostitutes

#15
kamal_

kamal_
  • Members
  • 5 240 messages
I've made a project for this. The Commoner AI project

Included on the discussion page is a thread that has templates (that were in Uncle FB's code) for single location and multi-location behaviors, so you can write your own behaviors to be added to this project. I'm going to focus on integrating Uncle FB's and Lugaid's existing behaviors, and injecting more randomness into them. There is also a thread on what I am hoping to accomplish.

#16
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
The remaining tasks really just come down to either creating new animations or using old animations in creative ways. Woodcutting could be attacking an i-point in a tree, clotheswashing could be using the labor animations near a pile of rags or a clothesline.

I could imagine another kind of generic script for some of the others, using my mingle script but with different animations added in. For example, the NPC could move to random NPC with a certain variable or tag, and perform the worship, plead, getlow, or bow animations, depending on whether they're soliciting ladies of the evening, slopping pigs, or saving souls.

Another neat script might be some sort of 'flock' behavior, where NPCs with the same variable or tag get together and then move as a group towards some other, random goal, like a pack of schoolkids either going to school or playing hookey.

If you can get a set of conventions going, I could start filling in the gaps.

BTW- do either of the expansion packs add any animations?

#17
kamal_

kamal_
  • Members
  • 5 240 messages

Lugaid of the Red Stripes wrote...

The remaining tasks really just come down to either creating new animations or using old animations in creative ways. Woodcutting could be attacking an i-point in a tree, clotheswashing could be using the labor animations near a pile of rags or a clothesline.

I could imagine another kind of generic script for some of the others, using my mingle script but with different animations added in. For example, the NPC could move to random NPC with a certain variable or tag, and perform the worship, plead, getlow, or bow animations, depending on whether they're soliciting ladies of the evening, slopping pigs, or saving souls.

Another neat script might be some sort of 'flock' behavior, where NPCs with the same variable or tag get together and then move as a group towards some other, random goal, like a pack of schoolkids either going to school or playing hookey.

If you can get a set of conventions going, I could start filling in the gaps.

BTW- do either of the expansion packs add any animations?

Exactly. Between your and Uncle FB's work the makings of a complete system are mostly already in there, with common cases already done and templates for new actions being defined. One beautiful thing FB did was provide templates for actions, making adding new behaviors something that can be done without a high level of scripting knowledge. Your work is also a nice building block, so that someone that sees that activity X is just an matter of combining y and z. You have things like the sap action (run to point, dig), that can easily be turned into run to x, do y.

I want to get something basic done over the weekend, adding time randomization and some place randomization to Uncle FB's stuff, and make sure that works. I've already put in various optional time randomizations into a script and included it into FB's script handling transition times. You can select totally random, bell curve, curves tilted towards the beginning or end of periods, etc by commenting in/out lines in my script. Once that's working I will add support for your behaviors to FB's scripts.

Ultimately I hope to have a system where a given commoner chooses their next activity randomly according to percentages the builder defines in the scripts, so not all farmers go to the inn at dinnertime for instance. When that's working I will start adding detection of things like the npc appearance, so you don't accidentally send off people in Red Wizard clothes to farm, maybe add a chance of a holiday with a different set of activity percentages so commoners don't do the same thing every day.

Yours and Uncle FB's scripts provide a great base for someone like me to work from. I can't program from scratch for crud, but I'm not too bad at working with existing code to get what I want.

#18
Eguintir Eligard

Eguintir Eligard
  • Members
  • 1 832 messages
make em go in the outhouse and back out

#19
kamal_

kamal_
  • Members
  • 5 240 messages

Eguintir Eligard wrote...

make em go in the outhouse and back out

I'm sure you're kidding but that behavior is not fundamentally different that stopping for a few minutes at a bard waypoint. Npc finds itself in radius x of a waypoint, y chance to take action z for a few minutes, then continue on their way. Assuming stopping for a bard is doable (and no reason to suppose it's not), bathroom breaks are doable to.

#20
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
You could write-in being scripthidden as another sort of animation, so they walk to the privy door, disappear for some time, then reappear later. Might even be able to get the door to open and shut, by setting the useable tag on and off.

I'm imagining two sets of functions, one to handle movement, and another to handle animations and other non-moving actions. A third set of functions would control the scheduling, with all the randomness that needs to be built in.

Might even program a Sims-style list of 'needs' for each NPC, that they seek to fulfill as they choose between their random actions, you know, bladder, entertainment, shopping, work, social. Then another table with weights for personality type. All of which can be randomly initiated at spawn, or set by local variables entered by the builder. Maybe have a set of variables on the area object to determine what mix of personalities and needs should be generated for that area (i.e. 10 peasants, 1 wizard, 3 drunks, 2 hooligans).

#21
kamal_

kamal_
  • Members
  • 5 240 messages
List of NWN2 animations http://nwn2.wikia.co...t_of_animations

Alban on IRC is working on goal oriented AI (eg Sims style). The demos are impressive, npc's can roam areas seeking choke points for instance, then defend them. Attacking a single commoner makes all nearby commoners run away from the player. I don't see it as something that could be worked in without a major rewrite of what I'm planning to do, and probably not worth it from a "people unlikely to notice/care" standpoint since I'm working on generic commoners.

Handling spawning in up to a max of x npc type is already something I had in mind. Including ability to set different npc mixes for different times of the day (more drunks and hooligans at night for instance) and different total numbers at different times (most people go to bed at night)

I've done some script renaming of your functions to break down what is done, Sap has become RunToPostAndDig for instance, your commentary is still in there on the original purpose. Hopefully these function names will be more self explanatory for different people and make it more understandable for builders who want to make new functions.

Right now I'm going through the activity code and replacing switch case statements with d100()>x to give people more precise control over probability of one sub-action over another (playing guitar vs bowing in the PlayGuitar action for example). Doing one small step at a time to the actions like this will hopefully keep bugs down. Found a few in Uncle FB code that I'm fixing (switch cases that couldn't happen for instance: int iRand = Random (7); case 0: .... case 7 [!] )

Oh yeah, woodchopping was requested. It's already in Uncle FB code, I missed it in my list.

#22
The Fred

The Fred
  • Members
  • 2 516 messages

kamal_ wrote...
No longer have nwn1, so maybe someone could dig up those scripts.

The scripts are in NWN2, amongst all the other legacy stuff that's left over. That's why I'm not sure if they will all work; there might be things missing, and certain animations have changed etc. But they should be there.

kamal_ wrote...
I'm adding the ability to set schedules to the minute instead of hour...

I don't know if you already know this, but the game counts up real-time minutes up to the number of minutes per hour, then sets it back to zero and increases the hour. Just like a real clock but there are however many minutes per hour you specify, not 60. I've been implementing some time functions myself and the real time/game time disparity caught me out a bit.

#23
kamal_

kamal_
  • Members
  • 5 240 messages

The Fred wrote...

kamal_ wrote...
I'm adding the ability to set schedules to the minute instead of hour...

I don't know if you already know this, but the game counts up real-time minutes up to the number of minutes per hour, then sets it back to zero and increases the hour. Just like a real clock but there are however many minutes per hour you specify, not 60. I've been implementing some time functions myself and the real time/game time disparity caught me out a bit.

I'll have to look into that. I'm calculating minutes since midnight, so if you wanted something to happen at 05:30 you'd enter 5(60)+30 = 330 minutes. If there's some real time/game time oddity I can certainly account for it, the current time tracking code's all in one spot, I can post it to the project page and you can improve on it.

#24
kamal_

kamal_
  • Members
  • 5 240 messages

The Fred wrote...

This is something on my to-do list as well, but I haven't even begun building populated areas like towns yet. I do have a nice system on the go where NPCs will go to their rooms at night-time, close the door and go to sleep (though they have no sleeping animation...). I'm using this for the academy-like Iron Circle, but it could be used for inns etc. The other stuff is still off on the horizon yet.

Sounds like you're volunteering to be a guinea pig... I mean tester :D

Right now the code is mostly like Uncle FB's, with the addition of Lugaid's functions, and would work like Uncle FB's. The big advances will come when I get to the point of removing the need for local ints on commoners in favor of checking iPoints, and then having the AI choose by percentage and select among multiple waypoints for the same activity.

There's plenty of work that's mostly time consuming between now and then, like the editing out FB's case statements for d100()>x to give greater control over the amount of different sub-actions making up one action.

#25
The Fred

The Fred
  • Members
  • 2 516 messages
By default, that would be 11 minutes past (5.5 hours x 2 minutes). It's not hard to adjust for that, though.

EDIT: I can send you my time code if you want, it's a bit of a WIP atm, but it seems to be working now.

Modifié par The Fred, 02 juillet 2011 - 11:58 .