seshbot-packing 0.9.1 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/seshbot/packing/recipe.rb +20 -1
- data/lib/seshbot/packing/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f77cf089e5f02caf10d7af67e7d75260d3529c560b2cfee232ba3b72f5f36e94
|
|
4
|
+
data.tar.gz: ec54cf2361668f1c92789f9337f0feb8f744a1208192e74368d46773eddf1f4f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1e5539df5a295507c496115dfda6f972310c24ed88dfc97a2712f55e8c852e2f4f64bde98168e4d626f7a7f5484cfdf472705c0f4fec6139f06e90620bbc8ad4
|
|
7
|
+
data.tar.gz: c482b9e179a56795a7ff2559d72f708ab27a684dae5e11f9d9fca423ea543752f80dd0e377cccbdb6241e6605b7ec20c75412bb5f4984e6d67caf7935e0fe28e
|
|
@@ -8,21 +8,40 @@ module Seshbot
|
|
|
8
8
|
# we want the recipe that is 'best' (packaging into as few items as possible, or unpacaging into as many as possible)
|
|
9
9
|
best_recipe = nil
|
|
10
10
|
best_recipe_output_quantity = nil
|
|
11
|
+
best_recipe_inputs_quantity = nil
|
|
11
12
|
recipes.each do |recipe_name, recipe|
|
|
13
|
+
recipe_inputs = recipe['inputs'].nil? ? [recipe] : recipe['inputs']
|
|
14
|
+
|
|
12
15
|
recipe_factor = _calculate_recipe_factor(recipe, items)
|
|
13
16
|
recipe_output_quantity = recipe_factor * recipe['output_quantity']
|
|
17
|
+
recipe_inputs_quantity = recipe_factor * recipe_inputs.map { |r| r['input_quantity'] }.sum
|
|
14
18
|
|
|
15
19
|
# is this recipe the 'best'? (if packaging, best is the one that creates fewest quantity)
|
|
16
20
|
is_best = if best_recipe_output_quantity.nil?
|
|
17
21
|
true
|
|
18
22
|
else
|
|
19
|
-
|
|
23
|
+
#
|
|
24
|
+
# the below code uses output as the main feature, but if they are equal uses the number of inputs
|
|
25
|
+
#
|
|
26
|
+
|
|
27
|
+
output_equal = recipe_output_quantity == best_recipe_output_quantity
|
|
28
|
+
|
|
29
|
+
# when packing, fewer outputs are better
|
|
30
|
+
output_better = unpacking ?
|
|
20
31
|
recipe_output_quantity > best_recipe_output_quantity :
|
|
21
32
|
recipe_output_quantity < best_recipe_output_quantity
|
|
33
|
+
|
|
34
|
+
# when packing, more inputs are better
|
|
35
|
+
inputs_better = unpacking ?
|
|
36
|
+
recipe_inputs_quantity < best_recipe_inputs_quantity :
|
|
37
|
+
recipe_inputs_quantity > best_recipe_inputs_quantity
|
|
38
|
+
|
|
39
|
+
output_equal ? inputs_better : output_better
|
|
22
40
|
end
|
|
23
41
|
|
|
24
42
|
if is_best
|
|
25
43
|
best_recipe_output_quantity = recipe_output_quantity
|
|
44
|
+
best_recipe_inputs_quantity = recipe_inputs_quantity
|
|
26
45
|
best_recipe = recipe
|
|
27
46
|
end
|
|
28
47
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: seshbot-packing
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shaun
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-04-
|
|
11
|
+
date: 2021-04-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email:
|