TooAngel / screeps

TooAngel NPC / bot / source code for screeps
https://screeps.com
GNU Affero General Public License v3.0
591 stars 154 forks source link

Auto build tunnels? #683

Open TSStudio opened 1 year ago

TSStudio commented 1 year ago

For room like this, build a tunnel is a better way to save carry creeps. image

TooAngel commented 1 year ago

I read about tunnels, never used them. Would be nice to have something in the code.

DefaultO commented 5 months ago

The thing about tunnels is, that they are insanely costly to maintain. Building 8 tunnels for one source isn't worth it at all. Building roads to all your remotes can be avoided by adding twice as many move parts for each carry part from what I experienced. This can boost the economy depending on what is cheaper.

Edit: I did the math earlier. And it appears to be cheaper than what Marvin exagerrated it as.

If you repair 100 hitpoints for 1 energy per work part. And the conversion rate isn't different (I never paid attention to it). You have to repair 15000 hitpoints every 1000 ticks for a road inside a wall. You can harvest 9000 energy from one source inside a reserved or claimed room in 1000 ticks.

So if that math is correct. You earn 9000 energy in the time it takes for you to burn through 5 * 150 (= 750) energy for the roads inside the wall alone. That still is a large profit margin.

TooAngel commented 5 months ago

K, thx for the insights. I guess there could be use cases where it make sense. If someone is interested in figuring these out, I think it would be a nice addition, but not mission critical :-)

DefaultO commented 5 months ago

Will see if I can code that in. What would be the best way to determine the path? What factors do we want the decision to influence?

Purely energy-wise, we shouldn't built a tunnel if there would be less than 150 roads (per tunnel) to maintain otherwise.

But tunnels can save us time it takes for energy to travel back to the base! So shouldn't we have to focus on the math or rather cost of more haulers it would need to keep a remote container consistently not full? Those are the complex solutions/formulas/algorithms logistics require. Thats what makes bots efficient. And having to solve these problems is what is fun about this game.

TooAngel commented 5 months ago

So, from https://docs.screeps.com/api/#StructureRoad, building costs 45k, it looses 15k per 1000 ticks, so 15 per tick - That is a lot. On plain it costs 300 to build, and 0.1 per tick. Looking at the numbers, I can't come up with many scenarios where it make sense.

Another tricky part to include it into the routing system. Right now the paths in each room are pre calculated an used by creeps when moving. So, when calculating the initial path it needs to be calculated if any tunnel would make sense.

I'm not sure if it is important that the energy arrives earlier.