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

Reduce cpu time for "find" operation #1

Closed
schoolie opened this issue Aug 7, 2018 · 7 comments
Closed

Reduce cpu time for "find" operation #1

schoolie opened this issue Aug 7, 2018 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@schoolie
Copy link
Collaborator

schoolie commented Aug 7, 2018

If you look at my creeps, most of them are running a "find" on every tick, which is expensive. We should make them use memory instead to find a target and store its ID only when switching from "not working" to "working" state or vice versa. Then they can move toward it until they can work/harvest and clear the target. If you start poking around, that would be a cool thing to work on.

@Schoolie440
Copy link
Owner

This has been partially solved. Most "working" tasks now use a "target" in memory. Sources are still being 'found' each tick. They need to be set as "creep.memory.target" in the not working state, and the script should be modified for this to function.

@Schoolie440 Schoolie440 added the enhancement New feature or request label Aug 16, 2018
@schoolie
Copy link
Collaborator Author

This is solved now, right? if so, go ahead and close it. Reference a PR or commit that fixed it if possible.

@Schoolie440
Copy link
Owner

Schoolie440 commented Aug 23, 2018 via email

@Schoolie440
Copy link
Owner

Oh, and the sources are still being found every tick as well, I just packed the old logic into a function to make things cleaner and more modifiable

@Schoolie440
Copy link
Owner

Made a further improvement to this, finally allowing sources to be stored in memory instead of being found every tick. At this point, I am pretty sure finds are only being run when target is null and a new target needs to be found. Closing issue.

commit cc29cf9

@Schoolie440
Copy link
Owner

The first issue ever is finally closed ;)

@schoolie
Copy link
Collaborator Author

and there was much rejoicing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants