@Itutorial The last commit from yesterday causes crash as soon as player sees monster
I have to do some more testing on it. So far I haven't had any problems including the one you mentioned but I will try some more things to cause problems.@Itutorial The last commit from yesterday causes crash as soon as player sees monster
working on it, I did a clean merge, also adding his latest commits to reduce memory but I encountered two segmentation faults.guys can you give us the proper order of the commits pls?
thank you very much can you shre that distro or is the same one as the previous commits?working on it, I did a clean merge, also adding his latest commits to reduce memory but I encountered two segmentation faults.
let's just be patient, @Itutorial is doing great job here
we're using pms so we don't spam the thread, this one is my own private repository but i'll do the merge on Greed fork as soon it works just fine (to don't merge unnecessary changes and keep it clean). But is what @omaraboud says, it crashes as soon an attack is done (either by monster or player).thank you very much can you shre that distro or is the same one as the previous commits?
static constexpr int32_t EVENT_CREATURE_THINK_INTERVAL = 200;
static constexpr int32_t EVENT_CREATURE_PATH_INTERVAL = 200;
Do benchmarks before and afterMore updates on this. First I highly recommend to disable windows update (if you're running on windows) before using this change.
The following video shows the pathfinding running at
- Press the Windows key + R, type services.msc in the run bar, and press the Enter key
- In the list of processes, locate Windows Update and open it by clicking on it.
- To deactivate it, in the "General" tab, look for the "Startup type" field and change it to "Disabled.
- Restart your PC, and automatic updates will be a thing of the past.
C++:static constexpr int32_t EVENT_CREATURE_THINK_INTERVAL = 200; static constexpr int32_t EVENT_CREATURE_PATH_INTERVAL = 200;
I tracked the memory usage at the side. I really didn't want it to be interrupted by any windows proccess (as possible). This was the outcome with 1 player, i'll be tracking with more players this week, but it seems to be hold at 80%. I don't recommend to run think/path intervals in "2000", at "500" the monsters overthink a little bit before moving. My best try at the moment was on 200/200, if this memory usage can be holded at 80% like it's shown in the video i'll keep it (or also try lower values, will see...)
The video I attached in the upper post is still being processed (your comment just came before it ended the process hehe). But here's a before (a test with this last commit added 8 months ago) Fir3lement 0.4 goToFollowCreature · ralke23/Greed-TFS-1.5-Downgrades@404c478 (https://github.com/ralke23/Greed-TFS-1.5-Downgrades/commit/404c478dd10811a9a2275bce9e0b94c18df0923c)) in the following video:Do benchmarks before and after
Indeed, it appears better, but I'm particularly interested in how much it has improved RAM usage, as it's one of my main concernsThe video I attached in the upper post is still being processed (your comment just came before it ended the process hehe). But here's a before (a test with this last commit added 8 months ago) Fir3lement 0.4 goToFollowCreature · ralke23/Greed-TFS-1.5-Downgrades@404c478 (https://github.com/ralke23/Greed-TFS-1.5-Downgrades/commit/404c478dd10811a9a2275bce9e0b94c18df0923c)) in the following video:
Unfortunatelly that time I tested it with Warlocks, but you can easily notice how "sticky" the monsters now are in comparission to before. Behemoths are glued to the character's pathfiding, meanwhile, Warlocks seems to be taking really good routes, but they can't hold the target like the new pathfinding does. Notice how I walk far from Warlocks and make them loose target, I bet that would not happen now (the warlock probably do a sticky follow from far).
We also tested fleeing monsters with @Itutorial but this material is enough to give it a try and bring more feedback.
Regards!
You should be able to leave the THINK_INTERVAL at 1000. It shouldn't effect pathfinding in any way. Make sure to update with the newest commits today. I fixed a couple problems. The system should be working 100%. Only time and testing will tell now.More updates on this. First I highly recommend to disable windows update (if you're running on windows) before using this change.
The following video shows the pathfinding running at
- Press the Windows key + R, type services.msc in the run bar, and press the Enter key
- In the list of processes, locate Windows Update and open it by clicking on it.
- To deactivate it, in the "General" tab, look for the "Startup type" field and change it to "Disabled.
- Restart your PC, and automatic updates will be a thing of the past.
C++:static constexpr int32_t EVENT_CREATURE_THINK_INTERVAL = 200; static constexpr int32_t EVENT_CREATURE_PATH_INTERVAL = 200;
I tracked the memory usage at the side. I really didn't want it to be interrupted by any windows proccess (as possible). This was the outcome with 1 player, i'll be tracking with more players this week, but it seems to be hold at 80%. I don't recommend to run think/path intervals in "2000", at "500" the monsters overthink a little bit before moving. My best try at the moment was on 200/200, if this memory usage can be holded at 80% like it's shown in the video i'll keep it (or also try lower values, will see...)
You can see some bench marks on the pull request for the main repoDo benchmarks before and after
I love the videos @ralke and @Itutorial ! It's great to see the monsters finally being responsive!You should be able to leave the THINK_INTERVAL at 1000. It shouldn't effect pathfinding in any way. Make sure to update with the newest commits today. I fixed a couple problems. The system should be working 100%. Only time and testing will tell now.
Additionally, you should leave the PATH_INTERVAL at 500-1000. The only time PATH_INTERVAL really does anything is when you stop walking or if the path to the character is blocked, then unblocked. (for instance a door opening and closing). The monster will have a delay to start chasing you which is the PATH_INTERVAL delay. Unless you walk after opening the door which will cause it to update as soon as you do.
Having the path interval any faster than 500ms will be depreciating results. Increasing the CPU and ram usage for only minor gains in reaction speed of the monsters.
With that being said, the new algorithm is 2x-100x faster than the previous one depending on the path. Faster meaning the CPU can process the path faster. As for how much memory is being allocated (ram performance) it is around the same 2x-100x because we are storing and iterating over a lot less nodes to draw the paths.
Post automatically merged:
You can see some bench marks on the pull request for the main repo
sorry to bothThe video I attached in the upper post is still being processed (your comment just came before it ended the process hehe). But here's a before (a test with this last commit added 8 months ago) Fir3lement 0.4 goToFollowCreature · ralke23/Greed-TFS-1.5-Downgrades@404c478 (https://github.com/ralke23/Greed-TFS-1.5-Downgrades/commit/404c478dd10811a9a2275bce9e0b94c18df0923c)) in the following video:
Unfortunatelly that time I tested it with Warlocks, but you can easily notice how "sticky" the monsters now are in comparission to before. Behemoths are glued to the character's pathfiding, meanwhile, Warlocks seems to be taking really good routes, but they can't hold the target like the new pathfinding does. Notice how I walk far from Warlocks and make them loose target, I bet that would not happen now (the warlock probably do a sticky follow from far).
We also tested fleeing monsters with @Itutorial but this material is enough to give it a try and bring more feedback.
Regards!
Followed the changes, using this commit (I noticed I had my own fork too much modified due the last pathfinding implementation, I mean, when the thread started like months ago). This was the outcome:These are the only changes you should have.
Optimize pathfinding by NRH-AA · Pull Request #4637 · otland/forgottenserver
Pull Request Prelude I have followed proper The Forgotten Server code styling. I have read and understood the contribution guidelines before making this PR. I am aware that this PR may be clo...github.com
if (!lookUpdated && lastMeleeAttack == 0 && !isFleeing()) {
if (updateLook && lastMeleeAttack == 0 && !isFleeing()) {
Itutorial said:The monster will have a delay to start chasing you which is the PATH_INTERVAL delay.
Now I tested this a bit further, I found it really important in enviroment like the one that is recorded on the video. This is only my first thoughts, but if the value is too high the pathfinding is too dependant of when you step. So being holding position can be used to confuse creature's pathfinding. Anyways, we can discuss about all this later on discord!Itutorial said:Additionally, you should leave the PATH_INTERVAL at 500-1000. The only time PATH_INTERVAL really does anything is when you stop walking or if the path to the character is blocked, then unblocked. (for instance a door opening and closing). The monster will have a delay to start chasing you which is the PATH_INTERVAL delay. Unless you walk after opening the door which will cause it to update as soon as you do.
void Creature::forceUpdatePath()
{
if (!attackedCreature && !followCreature) {
return;
}
g_dispatcher.addTask(createTask([id = getID()]() { g_game.updateCreatureWalk(id); }));
}
void Creature::forceUpdatePath()
{
if (attackedCreature || followCreature) {
const Position& position = attackedCreature ? attackedCreature->getPosition() : followCreature->getPosition();
if (g_game.isSightClear(getPosition(), position, true)) {
g_dispatcher.addTask(createTask([id = getID()]() { g_game.updateCreatureWalk(id); }));
}
}
}
static constexpr int32_t EVENT_CREATURE_PATH_INTERVAL = 200;
That looks good to me but at the same time I don't play RL tibia which I know is what we aim for. I would still make the the two changes I made today on the official PR. They are kind of critical and shouldn't change the behavior you just showed it will however fix a couple lags in pathfinding updates.@Itutorial Observe the monster's behavior... What do you mean? Was it good? Or should I make changes again?
I've already made the changes, all good, that you sent with the two PR links... they seem very good. I haven't noticed anything causing CPU abuse or something similar... it's at 0%. I added many monsters and tested it, and it's still at 0% and 05%. It didn't cause any problems... it's working perfectly. It seems good... Now I want to put it on a VPS to see how it works... Thank you for your work.That looks good to me but at the same time I don't play RL tibia which I know is what we aim for. I would still make the the two changes I made today on the official PR. They are kind of critical and shouldn't change the behavior you just showed it will however fix a couple lags in pathfinding updates.
Optimize pathfinding by NRH-AA · Pull Request #4637 · otland/forgottenserver
Pull Request Prelude I have followed proper The Forgotten Server code styling. I have read and understood the contribution guidelines before making this PR. I am aware that this PR may be clo...github.comOptimize pathfinding by NRH-AA · Pull Request #4637 · otland/forgottenserver
Pull Request Prelude I have followed proper The Forgotten Server code styling. I have read and understood the contribution guidelines before making this PR. I am aware that this PR may be clo...github.com