chiark / gitweb /
19a: much faster
authorBen Harris <bjh21@bjh21.me.uk>
Tue, 28 May 2024 08:17:30 +0000 (09:17 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Tue, 28 May 2024 08:17:30 +0000 (09:17 +0100)
We now don't build a robot if our production rate of it resource is
enough to build a new robot of the most expensive kind every minute.

19/19a.bqn

index 04653f636213551046816c4222ed77d79e78a258..d7f05cb0858b1129b794592313703c8b68aeb776 100644 (file)
@@ -28,7 +28,7 @@ EvalBlueprint←{𝕊 robot_costs:
       needed←(𝕩⊏robot_costs)-stock
       needed_time←1+0⌈⌈´⌈NtZ needed÷robots
       # Build a robot if there's time and we might need it.
-      (needed_time≤time)∧(𝕩⊑stock<max_costs×time) ?
+      (needed_time≤time)∧(𝕩⊑stock<max_costs×time)∧(𝕩⊑robots<max_costs) ?
       Search ⟨time-needed_time
        (stock+robots×needed_time)-𝕩⊏robot_costs
        (1⊸+)⌾(𝕩⊸⊑)robots⟩;