skyjay1 / GreekFantasy

Minecraft Forge mod that adds Greek-inspired creatures and items
Other
8 stars 5 forks source link

Ai step #120

Closed Looodon closed 2 years ago

Looodon commented 2 years ago

Hey, for some reason my game has gotten choppy and I downloaded a mod called Spark and ran a profiler. It showed that out of around 75 mods, Greek Fantasy 's server thread was at 69.13% (34.29ms) I don't know what any of this means, but I'm assuming it means its taking up most of the RAM. I have 12 GB of RAM and I dedicated 6 max to the game.

These are the results: (6 pictures)

Test 1 with all mods (69.13% Greek Fantasy, the rest were all around 0-1%)

1 2

Test 2 with only Greek Fantasy and Spark installed (46.8%)

6 3

Test 3 with all mods (relaunched the game and lowered dedicated RAM to 5 GB)

8 7

skyjay1 commented 2 years ago

I think I see the culprit. Have you ever run /locate structure xxxx and it takes 2-3 seconds for a response? Well, many Greek Fantasy creatures do that every 10 ticks to check for camps and structures to move toward. I reduce the range from 100 chunks to 3-5 chunks, which speeds it up, but it clearly needs more optimization. I'll work on this in future releases.

skyjay1 commented 2 years ago

Could you do me a favor and see if the game is still choppy with commit df20298 ?

Looodon commented 2 years ago

It looks like this time it wasn't as choppy, idk what caused it to be choppy it happens at random every day at a random time.

I complied the jar and used the one out of: Desktop\GreekFantasy-master-1.19\build\libs

Test 1: (played randomly for 2 mins)

The original version had a server thread of (9.38%/4.69ms) The new version had a server thread of (2.70%/1.35ms) = no red in the results

Test 2 (summoned 10 ara while walking in a straight direction)

Original: 12.45% / 6.21ms New: 2.84% / 1.42ms

Test 3 (summoned 30 ara)

Original: 24.12% / 12.06ms

New: 2.14% / 1.42ms

Test 4 (started a flat world and summoned 20 ara and 20 gigante 10 satyr)

Original: 1.39% / 0.69ms 1

New: 1.72% / 0.86ms 2

Looodon commented 2 years ago

Something that happened with the new version that didnt happen before is the Gigante came down from the top of the mountain all the way down

EDIT: also in both version, for some reason ara's always leave land to stand in rivers to stare down at fish

skyjay1 commented 2 years ago

Thank you for the detailed report! I added a 200-450 tick "cooldown" for the goal and staggered it to prevent every creature from running /locate in the same tick, but it looks like that wasn't enough to fix everything.

I think I will add config settings for the goal and set it to "off" by default for most mobs. The only ones that really need it are the Tritons, tamed Guardians, and bosses (Nemean Lion, Hydra). Maybe Ara and Centaurs too, but maybe not.

Looodon commented 2 years ago

if I had to pick between both I'd pick Centaurs over Aras, but if they both get it or both dont, all options make sense.

Idk anything about modding, but if its less resource intensive, maybe the AI for /locate can remain weaker, and a compensation can be that camps can act like a spawners do. if there arent any of that mob within 2-5 chunks itll spawn a few after a long time have passed (10-60 mins). That sounds more resource intensive to me though im just throwing ideas in case it was more efficient. Looking forward to seeing what you come up with, thank you!

Looodon commented 2 years ago

I checked an old profiler I ran on 9/24/2022 (2 week ago) cuz I had major lag but I didn't know how to interpret the results until a few days ago and I just thought id share the part that relates to the mod. Obviously this is uncommon and it hasn't happened to this bad of a level since. To be fair I did have another mod called AI Improvements at the time, which could have been the reason although its whole purpose is to simplify the AI, but I don't have that mod anymore (the previous tests above did not include Ai improvement mod). The issue isn't exclusive to Ara, but in cases where Aras are responsible they usually have the highest impact.

790