Inactive Three Tier AI

ReleeSquirrel

New Member
Cervator edit: Moved to Suggestions and marked inactive. Other AI threads have come since, but this one still has a lot of neat stuff!
Skaldarnar edit: Merged with Esereja 's AI thread, moved to incubator, added header


Name:Three Tier AI System
Summary: The Three Tier AI system is a concept for hierarchical AI design. Due to the hierarchical structure and the three tiered structure it can be used for animals, monsters and humanlike AI equally. AI behavior can be customized via json configuration.
Scope: Core
Current Goal: Working and customizable low level (tier 1) AI system (?), add social behavior
Phase: Design/Implementation
Curator: ReleeSquirrel, Esereja
Related: Miniions

One of the key systems I want to experiment with in Terasology is my idea of a three tiered AI system for person simulation.

The idea here is to simulate an AI complex enough to have humanlike interactions between AIs, and potentially with players as well. Ideally without breaking the bank on processor resources!

From what I've read about the mind, it's largely split between three levels. Animals that haven't changed much since ancient days still only have the first level or two, and humans are especially in the third. These are instinct, emotion, and reason. I think that these can be simplified in order to produce some really engaging artificial people.

Instincts are your basic actions. The simplest animals operate purely on instinct, like reflex. Pure input-output, event and response. Very simple. A fly doesn't dodge your hand because it thinks, "OH SNAP! A HAND!" it feels the air pressure and the shadow and moves automatically. That's why they're so hard to catch. Most AI operates like this too. Event, reaction. It makes them predictable and ultimately very controlable.

Instinct is easily modeled with a standard state-based AI system.

On top of instinct is emotion. Emotion is what you feel. They say there are six basic emotions. Anger, Disgust, Fear, Happiness, Sadness and Surprise. http://en.wikipedia.org/wiki/Emotion

Different basic emotions combine together, and with instincts, to form sub-emotions. When I first read about emotional theory I was surprised that Love isn't a basic emotion; it's actually a form of Happiness or Joy, combined with reproductive and familial instincts.

Emotions inform and influence our choices. We're less likely to trust someone who has hurt us before, and more likely to trust someone we like. If we're afraid of something, we'll be more on guard. We avoid what disgusts us, and try to get rid of it.

Emotions are often attached to things, so I feel the best way to model emotions is to use a target-emotion pair list. Now, keeping a list of how you feel about EVERYTHING would be kind of nuts, so I would trim this into two lists. One is your short-term immediate feelings, what you felt about the last ten things you interacted with perhaps, to guide your immediate actions. You might be mad at a person, but you don't have an everlasting hate for them. You might be afraid of a rock that nearly fell on you, but you wouldn't fear that rock or all rocks forever. Then there'd be a long-term emotion list, for things that are most important to you. How you feel about, say, the twenty or fourty most important people to you, like friends and family, as well as long-term grudges and fears.

Emotions would primarily inform the state machine. You act this or that way depending on your emotions. It becomes less reflex and more reaction, but it's still pretty simple. The third tier is where things really take off.

Reason is a special ability humans and some animals have, which allows us to predict the future and plan for it. Humans go way above and beyond any other animal though. We have really complex ideas like beliefs and plans and math and ethics. Effectively, Reason allows us to consider our situation and change our plans accordingly. Now, modeling that accurately would be kind of nuts. That's practically a turing level AI right there, isn't it? I don't think they've even got that working at MIT yet, and anyways it would take obscene amounts of processing power to handle even one AI at that level.

My idea for modeling reason in the three tier AI system is to use a collection of pre-scripted 'beliefs' along with a measurement for how firmly held that belief is, and to have the AI determine its course of action based on those beliefs. These beliefs will include things like ethics and personal goals. An ethic might be something like "Killing is Bad", and a personal goal would be something like "Own a House".

AIs would communicate with eachother to try and convince eachother of their beliefs. An example I gave someone while explaining this system before was an environmentalist and a litterbug. An environmentalist is hanging out by the river, and they see another NPC throw something away on the ground. The environmentalist gets angry because they saw someone violate one of their beliefs, and they go to talk to the litterbug. They share their belief with the litterbug, coloured by their emotion. The litterbug then compares the environmentalist's belief to their own beliefs. In this case, they will either accept the environmentalist's belief and feel ashamed, or they will find the environmentalist's belief to be against their current beliefs, or they just don't like his attitude, and they end up with a negative opinion of the environmentalism belief. These choices are informed by a person's beliefs, and their built-in 'persona', which would be something like a short stat tree of emotional variables like patience and empathy.

The top tier AI is pretty complex, which can be difficult. If the AI is constantly checking a list of values and reorganizing their own state machine based on them, I expect that will be pretty processor intensive. Especially if you have dozens or hundreds of these guys running around at once. So, I figure they'll only check their reason level once and a while, to make sure they're still on track, as well as when they have an ethical dilemna.

One thing I was thinking about, in order to minimize the impact of sudden reason checks, is to do them in extra processing room. Stardock did that with their Galactic Civilizations games. While the game is running, even if it's your turn, the AI machine is running in the background, thinking about what to do next in other threads. As a result, the AI is smarter the faster your computer is, and the slower you are. By drawing out reason checks over several frames, it could become a constant process without having a noticable impact on the game's standard processing.

Anyways that's the theory. I had been intending to test this AI theory in an application specifically designed for it; something like Animal Crossing where the player moves into a village and interacts with complex AIs. But I think it could work in Terasology too, giving us interesting NPCs to interact with, and letting them have more desires than work.

What do you guys think?

I have another system that I think would tie in well with this. I'll write that in another post when I have enough time.
 
Last edited by a moderator:

Skaldarnar

Development Lead
Contributor
Art
World
SpecOps
I'm searching for the "You're totally crazy but this could be awesome if implemented" - rate button...
Agree! :D

I would totally recommend you to talk with Perdemot , he started building up the basic AI system, so you two can work on tier after tier, making the AI more complex in each step, but keeping everything quite modular (maybe you want a crowded city with lots of dump NPCs on a slower PC rather than just one "human" that acts reasonable, but is alone in its environment...)

Maybe some kind of tier 2.5 could be (reasonable) interaction with the environment. What I am thinking about is city generation and city eggs. If we would not build all building by "magic", but rather offer blueprint to the NPCs they can interact with these hooks if they have the goal to own a house...
 

aherber

Member
Contributor
Architecture
ReleeSquirrel This sounds really interresting. I guess that there are alot challanges to overcome when it comes to ai in a procedural world in general. But i kind of like the idea of having a social ai. I think this could lead to some interessting and dynamic interactions between npcs and also the player.
Im not an expert when it comes to programming an ai. I guess its kinda like "teaching" a baby, (for the lack of a better analogy). Your approach reminds me of Prom Week http://www.kongregate.com/games/PromWeekPlaya/prom-week
.
This is a game or more an interactive story telling experiment by simulating social dynamics. In a Nutshell the underlying system of Prom Week is simulating the likes and dislikes of an indivividual as well as the (weighted) influance (opinion) of friends and relatives. So the AI estimates how much it likes or dislikes a person, conversation topic, behavoirs and so on. There is also a paper describing things in more detail http://games.soe.ucsc.edu/sites/default/files/TheProm-ELOAI.pdf. Whats interresting about this system is that allowed to define character traits. Like a person who is self destructive when it comes to social interactions and things alike. From what i understood one of the major challanges of this approach is that it needs a lot of data/rules to evaluate on. This data/rules also needed to be defined (more or less) by hand which took quite some time and people. If i remember rigth they have defined several thousands rules for this system . Im not sure how much rules would be needed in our game and if this approach is feasible, but it may be a starting point since things can be expanded later on. Im also not sure if there is a way to automize the generation of these rules or to have some sort of automated learning for likes and dislikes. I think this is a really hard problem. All i could think of is start small and see if it works and if its worth put more time into it. I hope this helps. And by the way im also looking for the" You're totally crazy but this could be awesome if implemented" - rate button. :cool:
 

ReleeSquirrel

New Member
I'm glad you guys like it! I had originally intended to write three big suggestion posts on the same day, but things got complicated. ^.^

Most of my ideas were originally designed for a largely 2D world, with maybe a handful of Z levels but no ground modification. So, there's a lot more going on in Terasology at the same time as any AI I throw together. We'll see how it goes.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Okay! Finally had time to read this, yay! I concur with the rating and am thinking about adding a new one for "crazy but awesome" - maybe Chunk Norris would work, just suggested a moment ago by a friend here at work ;)



So yes, I'd love to see where this could go, it seems a worthy system to match our crazy ideas on anatomy, combat, procedural generation, and so on. The nice part is that this seems a higher level system more independent of the vertical layering - more a guidance system for what to do than anything related to pathing. And I've wanted to assign ethics beliefs to the sentient races, like how in DF there are some ethic settings on races like whether they'll engaged in cannibalism, or freak out if something is spotted that is crafted from wood ;)

If you're up for starting a full design on it, let me know and I'll toss a contributor badge at you so you can post an Incubator thread on the topic - specifically for a decision system AI rather than pathfinding AI, as those two could be separate :)
 

ReleeSquirrel

New Member
I'll put something together eventually. I'm really busy this week and next, and I still want to finish figuring out how the game works in its current state.

I have a couple of other systems to put up here on the suggestions forum too, but I've been having trouble putting them into words. Maybe it would be easier if I explained the games I designed for the systems originally..
 

Esereja

Active Member
Contributor
I made Hierarchical Ai system(it works).It is rether complicated and has lot of option that you can set in json file(to make creeps or animals).

Now the guestion is what options it would need?
at moment it is difided in 3 main reflexses:
attack/run(danger/player)
feed(not ready)
walk around/ stay at place(randomly)

what other reflexses it would need?

at moment you can set:
how far it detecs player.
if it is agressive
if it is wild animal(runs away, if not agressive)(when i get that function work)
diferent update times

what else would you wan't to customize from AI?

now our qelatinous friends are much wiser.(and so hard to get rid of)
link to wikipedia: http://en.wikipedia.org/wiki/Robotic_paradigms

(I know other do work on this area too. but I just wanted to get creeps working somehow)
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Later edit: The two threads were merged.

Seen this thread ? You might want to poke ReleeSquirrel some about the topic, I thought it was a pretty good read and I like the options we have. Glad to see you're into it too :)

Social behaviors made up by more than one member of a group would be nice. Simple stuff is enough for testing. Say if two GelCubes of the same color ends up near each other they do a little dance and a new block is placed where they met. Something goofy like that :laugh:
 

Esereja

Active Member
Contributor
I will poke @ReleeSquirrel when i have time to write ptoper english.

And that social behavior will go into list of secondary objectives. I will include it into more complex class to keep this fast and somehow readable.

I just understood that by adding some functionality into AI(creeps die if go too far away from player)
we have allmost all to make platform game.
that funtoinality is useful for birds and insects, for those AI's that doest realy mater anyway. And in this case, I can make it kill qel cubes when they are too far and then spam more new ones.

and MAYBE some moding into health component, we have all to make some paltformer game maps whit portals.(run in high air on pilars away from qell cubes, that will try to HURT you)

we should have class that controls random creature spawning, and way to include it in mod. That way you can make new creature and in json give it spawnable component. After that it will start spawning in right biomes and such.
 

Skaldarnar

Development Lead
Contributor
Art
World
SpecOps
That sounds good already.
Would you mind merging these to threads - they seem to be very similar/dealing with the same topic. Keeping it structured from the beginning is easier than reordering everything. Moreover, we would have ONE starting point for AI developers, and only ONE incubator thread for discussing problems and stuff.
 

Esereja

Active Member
Contributor
sorry i have bad happit to create thread after another. need to learn get rid of that :). And thanks for merging it in here

My Ai would propaply be the first tier or in second. Depending how we look into it.
 

Skaldarnar

Development Lead
Contributor
Art
World
SpecOps
Ok, I've done the magic :pinkiehappy: The thread is now in Incubator as its a quite solid concept and you're working on it.

ReleeSquirrel, I've merged the threads as they are very similar. Maybe you could work together to build a hierarchical, json-cusotmizable, 3 tier AI system.

I'm looking forward to a good collaboration. ;)
 

Esereja

Active Member
Contributor
I Will propaply want to create also other types than hierarchial as practice. we do study them in university but don't go that deep. So this is perfect way to test diferent learning systems and ai aproaches(that something I realy must study for my research anyway).
 

Esereja

Active Member
Contributor
those qel cubes are so dangerous. you can't even run away of them. they just hun't you down and you are done. splashing all around and you never know where it will apear, and take care of you.

I made ai to hurt you if set agressive and hunt you if set so. now we need only proper spawning systmem and more creeps(models and setting) and we are ready to go.

I also coded in my own branch(not same as AI branch) weapon and damage system and I was wondering how it should be done, so need to look whit some one deeper into that.

scary qel cubes to all

added git pull reguest https://github.com/MovingBlocks/Terasology/pulls
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
For a combat / weapon system look to the work aherber has done already, it is nicely advanced based on physics, collisions, and fun stuff like that. Also probably best to discuss in that combat thread and stay focused on AI here :)
 

Esereja

Active Member
Contributor
I think we need spawnableComponent and spawnableSystem in main code so you can easly develop monster whitout depencies like to portal mod.

and that wild spawning(around player) is also usefull I think.
You could just create mod whit lot of prefabs and they would spawn by giving spawnable combonent.

In that combonent would be biomes, darknes level, and such things. Which decide if monster will spawn.

and also defaultMobFactory would be needed.

what you think about idea?
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Very fundamental stuff like spawning, assorted types of AI, etc, should be bundled with the game for sure, yes. That's where the terminology gets tricky. Some of these modules aren't traditional "mods" that are only there if the player wills it, instead we're trying to extract more stuff out of the game engine than normal. That way players and modders alike can more easily tweak and tinker, or even exclude some things if they're not needed.

woodspeople brought up an interesting point quite a while ago - she plays a challenging form of pacifistic Minecraft to approach the game from an unusual philosophical angle. In her experimenting with the game she realized that on "Peaceful" setting hostile mobs still actually get spawned, but then are immediately eliminated from the game. That can bring about both some unexpected takes on morality if you use the knowledge as such (from the viewpoint of the mobs that could be seen as genocide by an oppressive coder overlord) as well as an obvious design flaw - it would be much more sensible to simply not have a system present responsible for spawning hostile mobs active. That's where our Entity System and bundling everything as modules really shine :)

It also gets confusing though. Should we call the fundamental stuff we include with the base game something else, like library modules / resources? What about the stuff that together makes up "Survival mode" or a free style mod-less building mode? Where do what pieces go? And so on.

Anyway - those are topics for other threads. The portals module will eventually need to be split/renamed/something, but in the meantime lets discuss spawning details over there, any terminology fun in its thread, and stay focused on AI in here :)

As far as AI goes (and effectively other creature traits) then we need to come up with the Components and what they should contain, the Systems and how they should process stuff, then stick pretty much everything else in the prefabs. I've been tinkering with how to build creature / behavioral archetypes you could easily apply to prefabs or even species somehow, but that's still in the design phase - and probably deserves its own thread sometime.
 

Esereja

Active Member
Contributor
I was thinking about AI's social side in sauna whit friends from university(Finnish style of communication). And they came up whit rather good idea:

Lets have natural fitest survive system, predators and herbivore AI. More AI eats more health it gets, more health biger it gets(to some limit), if no food for certain time health goes lower, no health dead.

When ai reaches certain levewl health and meets other whit such they can multibly losing some health. When AI reaches 100X its health it will reach status indibended AI(creates new AI from it and destroy old) after which its suroundings will be active like it would be player. certain foods(leaf or other AI) give only certain ammount health and bigger AI get hunger faster(limits grow).

Thats how nature normaly would create bosses and such. And would give players reason to take care AI population so that no Alpha Males start geting too big.

and if spawning system would spawn AI realy rarely that also would give reason for players to avoid killing every AI in vision field( because it would be looooong time before you get new).

How you like the idea(I love it).

this way also dynamic envoirment that @woodspeople is developing, would be needed as otherwise herbivores will die out to lack of food(and then predators and then players, or maybe big predators would survive by eating players that come out of thin air).
 

Esereja

Active Member
Contributor
I got errors fixed, and added new mob: Hopper. Beavare these new curious fellows jump high and are even more deadly than qelcubes.

(I nerved qelcubes, added back normal neutral cubes)
 
Top