Comments (3)
What would you say is the most performance demanding part of the pathfinding? I found with mob spawns of 15+ the frames would only drop some of the time, but obviously more consistently at higher amounts.
Every mob checks every entity on the map through it's WAIT and HUNT state until it finds something to interact with, could there be much of an improvement to limiting the search range to the vision distance before processing direction or the target light levels?
from barony.
I would absolutely start this task by sorting different object types into different lists entirely, rather than having one enormous list of entities which is crawled through linearly every time we want to look up the object. The dangerous part is that the pointers in the entity list are the only "owners" of the object right now, and if you add additional lists referencing the same objects then you can end up creating dead references if you change/remove the data. For this reason we'd need a shared pointer system, and I wouldn't necessarily use the one that comes stock with C++ (convenient as it is) though that would certainly be a start.
At that point, I would also go the extra mile and replace the entity lists with hash tables, where the entity uid effectively takes the place of the hash (thus acting as the key index for an array of lists). That would greatly improve entity lookup times, which is important for speeding up other areas of the code (though a bit tangential to this issue...)
Finally, you'd have to deal with thread-safety. How do you find the path while entities are still moving in the world and changing the terrain? It wouldn't be too difficult to generate and pass an obstacle map to the thread which it can then use to find the path, rather than working with the raw level data... in fact, that would solve most of your problems right there. For an example on how to copy and store level data in memory, you could reference the undo/redo functions for the editor in editor.cpp.
Those are my thoughts on this :)
from barony.
Well 2 years later.. I can say we finally got somewhere.
Pathfinding now uses "entities on tile" checking rather than looping through every entity at every tile, generatePathMaps() as such longer a big deal, no lag when mining blocks.
Lots of entity lists were replaced by a creature-list which only needs to traverse the 20-30 monsters on a map instead of 600 entities.
from barony.
Related Issues (20)
- Restart after last player dies, game over screen appears after restart HOT 4
- [Linux] Cannot compile source code HOT 5
- Torches being used whilst transformed with no effect HOT 1
- ally repeat command while reading tutorial sign crashes game HOT 1
- Missing Images Directory HOT 1
- [Linux] Missing Menu Text on Unchanged Build HOT 3
- [Linux] [Steamworks] [4.0.2] Cannot build with steamworks HOT 1
- Surround sound backwards in Windows
- Asset Replacement Bug: Player, Item, and Block Replacement by Green Orb HOT 1
- Crash in Tinkering Tutorial HOT 3
- [Bug] Light Level Calculated incorrectly for low Stealth and negative perception
- [Windows][Multiplayer] Unplayable multiplayer via Steam: very long wait for interaction, weird teleportation between levels
- [Switch] Game crashes when attempting to view skill list HOT 2
- Broken textures: everything looks like green ball HOT 1
- Add NOGDI define for building on Windows
- [Switch] cant write in a online lobby
- Fix game stutters upon doing something for the first time HOT 3
- Debian 12 - GOG edition - Failed loading libpng12.so.0 HOT 1
- BUG: Some iterator out-of-bound access bugs HOT 1
- Some parts of the torch only displays ASCII characters. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from barony.