Jump to content

AI pathfinding of creatures still not fixed?


Recommended Posts

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?
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Developer

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
Link to comment
Share on other sites

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...
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.
Link to comment
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
 Share

×
  • Create New...