From d277dca9e238b938906e1ea942b1d4d2dd0910ec Mon Sep 17 00:00:00 2001 From: Adam Spragg Date: Sat, 31 Dec 2022 15:37:01 +0000 Subject: Puzzle 19: Don't build ore/clay robots when short on time Don't try building ore robots if there are fewer than 10 rounds remaining, or clays robots if there are fewer than 5. It's probably too late for those robots to make a difference? Maybe? (Why 5 and 10 rounds? Just a guess. And it seems to still get the right result) Drops time by 90% on 22-round test data (4.8s -> 0.4s) --- 19.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/19.c b/19.c index a534090..61ac737 100644 --- a/19.c +++ b/19.c @@ -260,6 +260,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 + && remaining > 5 && inventory_build(&test, b, CLAY) == 0) { // fprintf(stderr, "%d: building a clay robot (%ld)\n", remaining, test.clay.amount); @@ -272,6 +273,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 + && remaining > 10 && inventory_build(&test, b, ORE) == 0) { // fprintf(stderr, "%d: building a ore robot (%ld)\n", remaining, test.ore.amount); -- cgit v1.2.1