From ced5aaedc92f4de16e1c4ba5b2275f63b3079a5b Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Mon, 18 Dec 2023 15:33:11 -0500 Subject: change sorting logic to do what i actually wanted: put smelting as early as possible --- mc-resources.py | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'mc-resources.py') diff --git a/mc-resources.py b/mc-resources.py index dadd79d..f60f53f 100644 --- a/mc-resources.py +++ b/mc-resources.py @@ -333,22 +333,34 @@ while True: gathers = [] order = [] -while ts.is_active(): - ready_smelt = [] - ready_nonsmelt = [] - ready = ts.get_ready() +ready = [] + +while True: + ready += list(ts.get_ready()) + if len(ready) == 0: + break + ready_to_smelt = [] + leftover = [] for id in ready: recipe = chosen_recipes[id] if recipe is None: gathers.append(id) + ts.done(id) elif recipe[0] == 'smelt': - ready_smelt.append(id) + ready_to_smelt.append(id) + ts.done(id) else: - ready_nonsmelt.append(id) - ts.done(id) - ready_smelt.sort() - ready_nonsmelt.sort() - order += ready_smelt + ready_nonsmelt + leftover.append(id) + ready = leftover + if len(ready_to_smelt) == 0: + if len(ready) != 0: + ready.sort() + item = ready.pop(0) + order.append(item) + ts.done(item) + else: + ready_to_smelt.sort() + order += ready_to_smelt order.reverse() -- cgit v1.2.3