Sign in to follow this  
archblue1206

AI pathfinding of creatures still not fixed?

Recommended Posts

Irontaco    136

Brook's is simply getting ready for winter.Now let me stuff this meat into my mouth like a squirrel and go burrow in a hole somewhere away from the Walruses.

Share this post


Link to post
Share on other sites
Palpetinus    839

Very true!

Close, but since the game world is build on a grid, we can actually skip the raytrace and just step along the grid checking each one to see if it is either impassable (eg. water) or contains walls. If so, we do a proper pathfind. (Objects that are not walls are completely ignored for pathfinding purposes at the moment)

However, as already mentioned:

[*]We only pathfind over short distances, if it's more than about a screen away, we don't bother as it becomes more likely to be too expensive.

[*]Even if it's a short distance, and even if it look to you as though there is an obvious path, it's still possible for A* to take quite a few steps to find the path... so this is also limited. Basically we let the A* pathfinding run for a while, and if it hasn't found a path by then, we cancel the operation because we have to get on with running the rest of the game.

Two likely additions will address these later are hierarchical pathfinding, which will make it much more practical over long distances; and queuing up the pathfind to occur over several frames, instead of requiring it to complete either all or nothing in a single step, which would allow even very long paths to be computed (hopefully) without grinding your game to a halt.

We just need to budget the time to do those things :)

*furrows brow*

*goes back to making an igloo*

That's nice and all, but can't mobs just give up whatever they try to do after a while?

Share this post


Link to post
Share on other sites
Diezen    125

Winter is coming + Walruses + Igloos......I like where this is going.

I can only imagine snow walls... And possibly Igloos functioning like tents except instead of restoring hunger/sanity it'll restore warmth.

Share this post


Link to post
Share on other sites
Excess    55

That's nice and all, but can't mobs just give up whatever they try to do after a while?

Thing is, pigmen are afraid of the dark. They wouldn't just stand there until the night comes.

Perhaps an alternative could be that after a couple of seconds of running in the same spot, they would switch to a 10 seconds state of running on a random side-wise direction, and then give the go straight home approach another try.

They would probably still hit walls, but they would appear to try and circumvent the obstacle. It may not fix the problem, but it wouldn't hurt so much our suspension of disbelief.

Share this post


Link to post
Share on other sites
Palpetinus    839

Thing is, pigmen are afraid of the dark. They wouldn't just stand there until the night comes.

Perhaps an alternative could be that after a couple of seconds of running in the same spot, they would switch to a 10 seconds state of running on a random side-wise direction, and then give the go straight home approach another try.

They would probably still hit walls, but they would appear to try and circumvent the obstacle. It may not fix the problem, but it wouldn't hurt so much our suspension of disbelief.

Well, actually, it COULD fix their situation...

So... it's something :D

Share this post


Link to post
Share on other sites
Silvi    27

Thing is, pigmen are afraid of the dark. They wouldn't just stand there until the night comes.

Perhaps an alternative could be that after a couple of seconds of running in the same spot, they would switch to a 10 seconds state of running on a random side-wise direction, and then give the go straight home approach another try.

They would probably still hit walls, but they would appear to try and circumvent the obstacle. It may not fix the problem, but it wouldn't hurt so much our suspension of disbelief.

alternatively:

count distance between pig and house

check if pig is in sight of player

if pig is not in sight of player, despawn

if in sight, run vaguely around (with pathfinding), circumvent any walls and despawn.

If pig too far away from house, just run in panic in circles.

Hilarity ensues.

Share this post


Link to post
Share on other sites
Brook    583

That's nice and all, but can't mobs just give up whatever they try to do after a while?

Possibly! But if you'll step behind this curtain with me for a moment, I'll talk a bit about how I might approach deciding which path to take as it were, when implementing a solution.

On one hand, pathfinding is a well defined problem with known solutions, it's mostly a matter of finding the time to implement them. It's still technically challenging, but for the most part there are obvious problem parameters, and it's clear when the outcome is correct or not.

On the other hand however "give up whatever they try to do after a while" is much less well defined and doesn't have a concrete solution. For example, How long is "a while", and under what circumstances? What does it mean to "give up"? Perhaps most importantly (and least intuitively) is that determining "what they are trying to do" at any given point in the game may not be as straightforward as it seems.

There are a lot of smoke and mirrors involved in game development, and what appears to be a simple task like "go home" or "attack that bird" might actually be a collection of different triggers and behaviours, some happening in sequence, and others happening in parallel, many of which are used for multiple things and mixed together to give you the result you see in game. It could be an engineering feat in itself just to pinpoint and categorize what the current goal of the character is, in order to determine what it was that you wanted to give up.

We can certainly improve things in this area, and hopefully we'll get a chance to soon. We're always looking at ways to smooth out the edges of the AI behaviour to make the limitations less obvious.

But thankfully, if all goes according to plan, I'll be able to spend the next update working on improving the pathfinding so that it is not so inept over long distances, and also doesn't grind your computer to a halt. While I'm at it, I'll also be looking for ways of deceiving you behind the scenes to make the creatures in the game seem smarter than they really are!

alternatively:

count distance between pig and house

check if pig is in sight of player

if pig is not in sight of player, despawn

if in sight, run vaguely around (with pathfinding), circumvent any walls and despawn.

If pig too far away from house, just run in panic in circles.

Hilarity ensues.

The spiders already use a similar approach to this (as will walrusser). Unfortunately it's not generalized to all creatures (yet?), but it's likely that we will be doing something very similar to this with the pigs too.

Now if you'll kindly look into this light...

post-1038-13764591329354_thumb.jpg

Edited by Brook

Share this post


Link to post
Share on other sites
Silvi    27

The spiders already use a similar approach to this (as will walrusser). Unfortunately it's not generalized to all creatures (yet?), but it's likely that we will be doing something very similar to this with the pigs too.Now if you'll kindly look into this light...[ATTACH=CONFIG]3702[/ATTACH]

I gazed into the code without lookin into the - uuu pretty collors.Edit: so THATS why sometimes I hear spiders but they disappear with dawn. Interesting...

Share this post


Link to post
Share on other sites
Palpetinus    839

Now if you'll kindly look into this light...

[ATTACH=CONFIG]3702[/ATTACH]

Wait what? Who are you people? What am i doing here?!

Possibly! But if you'll step behind this curtain with me for a moment, I'll talk a bit about how I might approach deciding which path to take as it were, when implementing a solution.

On one hand, pathfinding is a well defined problem with known solutions, it's mostly a matter of finding the time to implement them. It's still technically challenging, but for the most part there are obvious problem parameters, and it's clear when the outcome is correct or not.

On the other hand however "give up whatever they try to do after a while" is much less well defined and doesn't have a concrete solution. For example, How long is "a while", and under what circumstances? What does it mean to "give up"? Perhaps most importantly (and least intuitively) is that determining "what they are trying to do" at any given point in the game may not be as straightforward as it seems.

There is a lot of smoke an mirrors involved in game development, and what appears to be a simple task like "go home" or "attack that bird" might actually be a collection of different triggers and behaviours, some happening in sequence, and others happening in parallel, many of which are used for multiple things and mixed together to give you the result you see in game. It could be an engineering feat in itself just to pinpoint and categorize what the current goal of the character is in order to determine what it was that you wanted to give up.

We can certainly improve things in this area, and hopefully we'll get a chance to soon. We're always looking at ways to smooth out the edges of the AI behaviour to make the limitations less obvious.

But thankfully, if all goes according to plan, I'll be able to spend the next update working on improving the pathfinding so that it is not so inept over long distances, and also doesn't grind your computer to a halt. While I'm at it, I'll also be looking for ways of deceiving you behind the scenes to make the creatures in the game seem smarter than they really are!

Regarding pigs, they could, when not finding a path, check if the obstacle is a wall after some seconds and attack it.

It's always so diappointing to see caged pigs. I mean, they are (kinda) intellegent creatures, and they get blocked by some simple straw in their way.

Share this post


Link to post
Share on other sites
fear_town    13

I have no idea what you guys are talking about.. Last thing I remember was driving home.. Now my cars all wonky and up a tree.. Now all I want to know.. Who was driving my car? And who do I bill?

Share this post


Link to post
Share on other sites
Karma Hound    10

I have no idea what you guys are talking about.. Last thing I remember was driving home.. Now my cars all wonky and up a tree.. Now all I want to know.. Who was driving my car? And who do I bill?

Obviously the tree for trying to steal your car.

Share this post


Link to post
Share on other sites
Palpetinus    839

What makes you so sure I don't live on mars or something? Other then the fact that it would kill me...

The fact that earth is the only planet inhabitable by humans in our solar system. (Which is the same as if i just said "the fact that it would kill you" :DBut i was wrong anyways, i forgot that the world exists in 3d. I would need a third location.

Share this post


Link to post
Share on other sites
Karma Hound    10

The fact that earth is the only planet inhabitable by humans in our solar system. (Which is the same as if i just said "the fact that it would kill you" :D

So you're saying you have no proof? I think my work is done here...

Share this post


Link to post
Share on other sites
Palpetinus    839

So you're saying you have no proof? I think my work is done here...

Yes, i have no proof. I ninja-edited. Read again.

- - - Updated - - -

Problem: alot of people here are not human.

Like, robots like you?

Share this post


Link to post
Share on other sites
Karma Hound    10

Yes, i have no proof. I ninja-edited. Read again.

- - - Updated - - -

Like, robots like you?

Well then, I guess I was wrong? Its not fully proof so I'm correct, I think... I'll just call it a write.

Share this post


Link to post
Share on other sites
Palpetinus    839

Well then, I guess I was wrong? Its not fully proof so I'm correct, I think... I'll just call it a write.

Yes, technically you are correct.But the voices in my head say you are a liar and i should kill you.

Share this post


Link to post
Share on other sites
sirmentlegen    507

Like, robots like you?

You are also a Popsicle.

- - - Updated - - -

Yes, technically you are correct.

But the voices in my head say you are a liar and i should kill you.

Oh ill kill you both, happy?

Share this post


Link to post
Share on other sites
Palpetinus    839

You are also a Popsicle.

- - - Updated - - -

Oh ill kill you both, happy?

Only if i get bacon first.

I am afraid those voices are the ones lying and should hence forth be killed. But since they are in your head the only way to kill them is to kill yourself.

Well, i can't kill anybody, since i am just a Popsicle.

Share this post


Link to post
Share on other sites
Karma Hound    10

Oh ill kill you both, happy?

Well I'm not sure I'd be feeling happy about anything right about then... Maybe start by killing him first, and if I like it then you can finish it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this