diff options
author | Adam Spragg <adam@spra.gg> | 2022-12-31 16:45:21 +0000 |
---|---|---|
committer | Adam Spragg <adam@spra.gg> | 2022-12-31 16:45:21 +0000 |
commit | 583046b8aba49d8a7da9055cbab762e921313fcc (patch) | |
tree | 3da22903bb323d2e37773cd9fc53dc2bd0e2472c | |
parent | d9749f519f1587ce6be9acb5617fe1300d95da3b (diff) |
Puzzle 19: Don't build a type of robot if we have lots of that resource
We obviously have enough of that resource at this time, so there's no
need for another robot yet.
Drops time by 60% on full 24-round test data (4.6s -> 1.8s)
-rw-r--r-- | 19.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -256,6 +256,7 @@ inventory_build_exhaustive(struct inventory * i, struct blueprint const * b, int // Try building a obsidian robot, and checking if that's better than anything else if (i->bsdn.robots < b->max_bsdn + && i->bsdn.amount < 2 * b->max_bsdn && inventory_build(&test, b, BSDN) == 0) { // fprintf(stderr, "%d: building a bsdn robot (%ld)\n", remaining, test.bsdn.amount); @@ -268,6 +269,7 @@ inventory_build_exhaustive(struct inventory * i, struct blueprint const * b, int // Try building a clay robot, and checking if that's better than anything else if (i->clay.robots < b->max_clay + && i->clay.amount < 2 * b->max_clay && remaining > 5 && inventory_build(&test, b, CLAY) == 0) { @@ -281,6 +283,7 @@ inventory_build_exhaustive(struct inventory * i, struct blueprint const * b, int // Try building a ore robot, and checking if that's better than anything else if (i->ore.robots < b->max_ore + && i->ore.amount < 2 * b->max_ore && remaining > 10 && inventory_build(&test, b, ORE) == 0) { |