summaryrefslogtreecommitdiff
path: root/19.c
diff options
context:
space:
mode:
authorAdam Spragg <adam@spra.gg>2022-12-31 16:45:21 +0000
committerAdam Spragg <adam@spra.gg>2022-12-31 16:45:21 +0000
commit583046b8aba49d8a7da9055cbab762e921313fcc (patch)
tree3da22903bb323d2e37773cd9fc53dc2bd0e2472c /19.c
parentd9749f519f1587ce6be9acb5617fe1300d95da3b (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)
Diffstat (limited to '19.c')
-rw-r--r--19.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/19.c b/19.c
index 2700712..2a86c26 100644
--- a/19.c
+++ b/19.c
@@ -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)
{