Jump to content

Applying mass pathfinding


Jambutters
 Share

Recommended Posts

How would I go about doing that?

Applying a mass pathfinding to lets say over 800-1300 mobs, without killing the client or server sides ram and cpu usage. 

Also does rendering that many mobs on the screen kill the clients cpu/ram? Most likely will be using pixijs for rendering.

Link to comment
Share on other sites

Pixi should be able to handle ~1000 sprites with little effort, depends on size and texture swapping but it'll likely be fine. Try to use a texture atlas where possible to reduce expensive calls.

For pathfinding, cheat as much as possible, for example, if units are a long way off and not visible by the player then there is (maybe) no need to plot their course exactly, you could just make an approximation of how long it will take them to move from A to B and just move them, no need for a path.

Similarly, can you group the entities in such a way that they share a path? If your path generates a series of points then you could introduce some jitter or variation to how each entity follows those points so that each individual path might seem slightly different but the expensive path operation is performed only once.

Use the cheapest path finding algorithm you can and plot short paths, possibly using an even cheaper method to guess intermediate points for longer paths and then stagger plotting those smaller paths.

Limit your AI to spending only so much time processing path finding, JS is single-threaded and you probably don't need to be calling out to web workers for short algorithms like path finding, you don't want your path finding hogging all the CPU when it is under load, try to spread the load out. Note that this is rarely trivial, test if you need to do this.

For lower powered devices/machines can you reduce the number of entities in the world? Or segment the world more drastically so that you effectively drop the entity number per chunk.

Test test test. You might be surprised at how fast JS can be. Never optimise before you have performance tests that firstly inform whether you even need to optimise and secondly tell you how your optimisation work is actually going.

Link to comment
Share on other sites

On 5/20/2016 at 10:51 PM, mattstyles said:

Similarly, can you group the entities in such a way that they share a path?

They all should generally share the same path to path to the players(due to them being zombies lol, they should be a bit dumb). Alright thanks for answering my question matt.
Hopefully it doesn't kill the server side of things, along with bandwidth when I put this into action lol.
 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...