grimoire 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/lib/grimoire/solver.rb +12 -3
- data/lib/grimoire/unit_score_keeper.rb +10 -1
- data/lib/grimoire/utility.rb +1 -1
- data/lib/grimoire/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6edd571b20c68657154ccebb7e415844163e2021
|
4
|
+
data.tar.gz: c840f072f9a7ea4e7542e1a2243ed9b7b6b6b580
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9588422c6b487a94fb009f75021499a918e7ffcf5fc247c1c1b4299b8a845170e0c2396b056a978dd04ef5018e434b1f1de71ed658adc0bfd99514e87278fa68
|
7
|
+
data.tar.gz: 6e73d8db9e4b7a82339cc4a7beb1673158cee6db83f76da3d904efe7a5939720f081aa9f9df638b6350bd264fa4e9d2f503942ba82044e5b7900a67b6cb6c35d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# v0.2.0
|
2
|
+
* Use direct `#to_json` to prevent conversion errors on older ruby
|
3
|
+
* Add `UnitScoreKeeper#preferred_score` to provide some score meaning
|
4
|
+
* Pass scoring preference through to queue init
|
5
|
+
* Provide current index to score keeper when requesting score
|
6
|
+
|
7
|
+
_ BREAKING CHANGES_: `UnitScoreKeeper#score_for` must now accept two parameters
|
8
|
+
|
1
9
|
# v0.1.6
|
2
10
|
* Add debug output if UI is available for output
|
3
11
|
* Update exception errors to provide more detail/context
|
data/lib/grimoire/solver.rb
CHANGED
@@ -54,12 +54,21 @@ module Grimoire
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
+
# @return [Bogo::PriorityQueue]
|
58
|
+
def create_queue
|
59
|
+
if(score_keeper)
|
60
|
+
Bogo::PriorityQueue.new(score_keeper.preferred_score)
|
61
|
+
else
|
62
|
+
Bogo::PriorityQueue.new
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
57
66
|
# @return [Smash<{Unit#name:Bogo::PriorityQueue}>]
|
58
67
|
def queues
|
59
68
|
memoize(:queues) do
|
60
69
|
Smash[
|
61
70
|
world.units.map do |name, items|
|
62
|
-
queue =
|
71
|
+
queue = create_queue
|
63
72
|
populate_queue(queue, items)
|
64
73
|
[name, queue]
|
65
74
|
end
|
@@ -88,7 +97,7 @@ module Grimoire
|
|
88
97
|
# @return [Numeric] score
|
89
98
|
def score_unit(unit, score)
|
90
99
|
if(score_keeper)
|
91
|
-
score_keeper.score_for(unit) || score
|
100
|
+
score_keeper.score_for(unit, score) || score
|
92
101
|
else
|
93
102
|
score
|
94
103
|
end
|
@@ -100,7 +109,7 @@ module Grimoire
|
|
100
109
|
# @return [self]
|
101
110
|
def reset_queue(name)
|
102
111
|
queue = populate_queue(
|
103
|
-
|
112
|
+
create_queue,
|
104
113
|
world.units[name]
|
105
114
|
)
|
106
115
|
queues[name] = queue
|
@@ -3,11 +3,20 @@ require 'grimoire'
|
|
3
3
|
module Grimoire
|
4
4
|
class UnitScoreKeeper < Utility
|
5
5
|
|
6
|
+
# Define meaning of score by what should be preferred. This is
|
7
|
+
# used by the solver to apply correct sorting to the queues.
|
8
|
+
#
|
9
|
+
# @return [Symbol] :lowscore or :highscore
|
10
|
+
def preferred_score
|
11
|
+
:lowscore
|
12
|
+
end
|
13
|
+
|
6
14
|
# Provide score for given unit
|
7
15
|
#
|
8
16
|
# @param unit [Unit]
|
17
|
+
# @param idx [Integer] current order index
|
9
18
|
# @return [Numeric]
|
10
|
-
def score_for(unit)
|
19
|
+
def score_for(unit, idx)
|
11
20
|
raise NotImplementedError.new 'No scoring has been defined'
|
12
21
|
end
|
13
22
|
|
data/lib/grimoire/utility.rb
CHANGED
data/lib/grimoire/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grimoire
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Roberts
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bogo
|