Schoolie440 / ScreepsCoop

Brian, Joe, and Ben's Coop Screeps Repo
0 stars 1 forks source link

Reduce cpu time for "find" operation #1

Closed schoolie closed 5 years ago

schoolie commented 5 years ago

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 commented 5 years ago

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.

schoolie commented 5 years ago

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

Schoolie440 commented 5 years ago

Not entirely, I thought I had put a comment on here describing it, but our store creeps are still running a find on every tick. We need to modify worker manager so that the store creeps can go to a target, fill it, and then receive a new Target from worker manager without a trip to the source.

On Thu, Aug 23, 2018, 4:45 PM Brian Schoolcraft notifications@github.com wrote:

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

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/schoolie3344/ScreepsCoop/issues/1#issuecomment-415565081, or mute the thread https://github.com/notifications/unsubscribe-auth/AGh19G31ZsDckPeLCrRnj26Lxg4sI0cKks5uTxRMgaJpZM4VybyM .

Schoolie440 commented 5 years ago

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 commented 5 years ago

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 cc29cf9993f7532f0a5ac81d7f47a1d2508fcac2

Schoolie440 commented 5 years ago

The first issue ever is finally closed ;)

schoolie commented 5 years ago

and there was much rejoicing!