Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMPROVEMENT] Manual Attack Optimization #94

Closed
MutinCholer opened this issue May 23, 2024 · 3 comments
Closed

[IMPROVEMENT] Manual Attack Optimization #94

MutinCholer opened this issue May 23, 2024 · 3 comments
Assignees

Comments

@MutinCholer
Copy link

MutinCholer commented May 23, 2024

In #76, the problem with performance came down to the foreach loop calling the trace line function more often than it should even with other statements preceding it. While I initially suggested that the trace line function should be called only once, it turns out that it can cause the survivor bots to occasionally not shoot the common infected if the visible one is farther away than the closer one that cannot be seen as you have pointed out in the previous issue.

My new proposal would be to add all common infected to a local array and then sort all of the entities in the array from the closest to farthest distance before the trace line checks are performed in another foreach loop. This allows the next closest common infected to be targeted instead of ignoring the closer one that cannot be seen.

From my testing, the performance improvements can be quite massive when dealing with a lot of common infected at once. This is most noticeable in some custom campaigns that spawn way more common infected than necessary (especially in Glubtastic 3's train chapter).

Here are two videos showcasing the difference in performance using two different methods when faced with 200 common infected.

https://github.com/smilz0/Left4Bots/assets/64824187/01aac2f6-1f6d-47a9-b809-c8a88c0ff21a
^Old Method (Trace line in one foreach loop)

https://github.com/smilz0/Left4Bots/assets/64824187/d56156b4-a643-4a00-a955-daa31f9663de
^Proposed Method (Trace line in ordered foreach loop)

And here is the ZIP file containing the left4bots_afterload.nut file if you would like to take a look at it.

Manual Attack Optimization.zip

@MutinCholer MutinCholer changed the title [IMPROVEMENT] Manual Attack Optimizations [IMPROVEMENT] Manual Attack Optimization May 23, 2024
@4512369781
Copy link

I did something similar, but I grouped the infected every 32 distances, then sorted them, and finally did tracing. Apparently your method is simpler and faster.

  1. minDist = 999999999; no need do this, just 'minDist = radius'.
  2. The priority of the tank should be higher than common infected, otherwise bots will ignore tank before killing all the common infected they can see it. But we also don't want to bots stuck on CI, so if tank is there, always kill CI in 120 radius first.
  3. About witch and tank, I think no needed to check is bots facing them, they always will look at it, just not shoot sometimes.
  4. Except common infected, don't check "m_lifeState", because special/boss infected will delete from the tables when they dead.
  5. Should build based on the latest version, v2.0 has bug in "Left4Bots.FindBotNearestEnemy" function.

my edit: edit.zip

@smilz0
Copy link
Owner

smilz0 commented May 24, 2024

Thanks guys, give me some time to test it.

smilz0 added a commit that referenced this issue Jun 1, 2024
Closes #91
Closes #92
To test: #94
@smilz0
Copy link
Owner

smilz0 commented Jun 1, 2024

Hey guys, i updated the /out version with this change but i made a little change to it. I removed minDist because i think in some cases it would have caused issues.
Basically if the first checked infected was a close one, it was added to the array and minDist was updated with its distance but with the if "dist < minDist" all the next infected were going to be skipped. Now, most of the times the closer infected is likely to be visible to the bot so no problem, but if that infected was not visible that resulted in the bot not shooting any infected.
Let me know if i made a mistake with this or i added any other bug.

Also, @MutinCholer can you add me on steam?

@smilz0 smilz0 closed this as completed Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants