summaryrefslogtreecommitdiff
path: root/mc-resources.py
diff options
context:
space:
mode:
authorBenji Dial <benji@benjidial.net>2023-12-18 15:33:11 -0500
committerBenji Dial <benji@benjidial.net>2023-12-18 15:33:11 -0500
commitced5aaedc92f4de16e1c4ba5b2275f63b3079a5b (patch)
treeda6e2054a5a97be3d511a12906f4a0387596a6f9 /mc-resources.py
parentb73c7686002d703edcc1e8acc45cc7b12832a697 (diff)
downloadmc-resources-main.tar.gz
change sorting logic to do what i actually wanted: put smelting as early as possibleHEADmain
Diffstat (limited to 'mc-resources.py')
-rw-r--r--mc-resources.py32
1 files changed, 22 insertions, 10 deletions
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()