Godofdrakes / barrows-potential

Indicates which monsters you should kill in order to achieve the desired Barrows reward potential
BSD 2-Clause "Simplified" License
0 stars 2 forks source link

Inconsistent Potential Plan #5

Closed Infinitay closed 3 hours ago

Infinitay commented 1 month ago

I've noticed that the potential plan on the NPC's to kill in order to reach the maximum potential for the desired reward is inconsistent in that it changes what NPC to kill if you don't kill the first NPC listed.

I'm choosing blood runes and have everything but crypt spiders and their giant variant enabled. The initial plan recommended to me is the following:

x2: Skeleton x1: Bloodworm

The issue is that this changes depending on what I kill first. For example, if I kill a skeleton first, then the plan stays the same and says,

x1: Skeleton x1: Bloodworm

but if I were to kill a Bloodworm first, I get a new plan recommended to me,

x3: Bloodworm

and if I kill a skeleton right after, then it changes back to

x1: Skeleton

Why is it that the reward changes depending on the order? If the initial recommendation is 2x Skeletons and 1x Bloodworm, how come choosing to kill the Bloodworm first changes the entire plan? Shouldn't it stay the same?

Godofdrakes commented 1 month ago

This is a quirk of the "optimal NPC" planner.

Because I was lazy keeping things simple I opted not to actually track what NPCs the player defeated. I also specifically wanted to support going off-plan because sometimes there wern't any "optimal" NPC spawns and I'd need to just kill whatever. To that end, the plugin does not track what NPCs the player defeats. It just notices the score has changed and recalculates the plan.

The Bloodworm case is a known issue. Four Bloodworms will result in a score of 876. while one Bloodworm and two skeletons will result in a score of 874. So the bug is that it's not telling you to do four Bloodworms in the first place. I wanted to ensure the game didn't hitch when the plan was updated (some other plugins do that and it always bugs me) so I capped how much time it was allowed to spend trying to find the "optimal" plan.

If you want to know the technical details, the planner is an A* implementation limited to 20 iterations. It attempts to find the highest scoring plan that doesn't exceed the target score. In an effort to prioritize shorter plans it will try to build plans out of higher value NPCs before trying lower value ones. Bloodworms are 2nd lowest value NPC with a combat level of 52. The result of all this is that the planner will find a "x2 Skeleton, x1 Bloodworm" plan with a score of 874 and then hit the iteration limit before finding the "x4 Bloodworm" plan. By killing a bloodworm first you reduce the target score the planner is working towards, reducing the number of iterations it takes to find the highest score plan.

There are some possible solutions to this. I could make the planner prefer lower value NPCs? It would result in consistent behavior but it would always give you a plan that's "kill 20 rats" and most people (or at least I) don't want that. Maybe I need to tinker with which NPCs it prefers to make plans out of? Make it prefer only NPCs that the player can currently see?

The "optimal" plan stuff is definitely not perfect. I've been on a bit of a hiatus from RS for a while and haven't run Barrows in even longer so I haven't really looked into further improvements, just major bug fixes like the overlay getting stuck on. If the planer changing the plan bothers you turning off both the "optimal NPC" settings will disable it. The "highlight NPC" setting is a simple "would this NPC put me over the target score" check and won't give you inconsistent behavior.