grimoire 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/grimoire.rb +1 -0
- data/lib/grimoire/solver.rb +11 -4
- data/lib/grimoire/unit_score_keeper.rb +15 -0
- data/lib/grimoire/utility.rb +4 -0
- data/lib/grimoire/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 200bc22b954a33f6ec11d2a41403afafacc3fe35
|
4
|
+
data.tar.gz: e2ebba16137affccdf764c24c08132f8668bc6ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4dbcf9162fe2846c739bb71fd1a9d50e87a7f843841663b0c7878917dbbf2dbab2a6ef004498543a3d07ba03c14806e714da846f15e523918c9f9fb434f5516
|
7
|
+
data.tar.gz: fa8a7d53d999489bf596f3ffbf1f77d5fd04ee68b3b5e3e236aab6dc2df230f55d75f4100cca5e9a6e1d3c4d00c703e813052a1cf87cd64e5042d771be42aa9d
|
data/CHANGELOG.md
CHANGED
data/lib/grimoire.rb
CHANGED
data/lib/grimoire/solver.rb
CHANGED
@@ -11,6 +11,7 @@ module Grimoire
|
|
11
11
|
|
12
12
|
attribute :requirements, RequirementList, :required => true
|
13
13
|
attribute :system, System, :required => true
|
14
|
+
attribute :score_keeper, UnitScoreKeeper
|
14
15
|
|
15
16
|
# @return [System] subset of full system based on requirements
|
16
17
|
attr_reader :world
|
@@ -60,9 +61,11 @@ module Grimoire
|
|
60
61
|
# @param units [Array<Unit>]
|
61
62
|
# @return [Bogo::PriorityQueue]
|
62
63
|
def populate_queue(p_queue, units)
|
63
|
-
|
64
|
-
|
64
|
+
i = 0
|
65
|
+
units = units.map do |unit|
|
66
|
+
[unit, score_unit(unit, i += 1)]
|
65
67
|
end
|
68
|
+
p_queue.multi_push(units)
|
66
69
|
p_queue
|
67
70
|
end
|
68
71
|
|
@@ -70,9 +73,13 @@ module Grimoire
|
|
70
73
|
#
|
71
74
|
# @param unit [Unit]
|
72
75
|
# @param score [Integer] current score
|
73
|
-
# @return [
|
76
|
+
# @return [Numeric] score
|
74
77
|
def score_unit(unit, score)
|
75
|
-
|
78
|
+
if(score_keeper)
|
79
|
+
score_keeper.score_for(unit) || score
|
80
|
+
else
|
81
|
+
score
|
82
|
+
end
|
76
83
|
end
|
77
84
|
|
78
85
|
# Repopulate the given queue
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'grimoire'
|
2
|
+
|
3
|
+
module Grimoire
|
4
|
+
class UnitScoreKeeper < Utility
|
5
|
+
|
6
|
+
# Provide score for given unit
|
7
|
+
#
|
8
|
+
# @param unit [Unit]
|
9
|
+
# @return [Numeric]
|
10
|
+
def score_for(unit)
|
11
|
+
raise NotImplementedError.new 'No scoring has been defined'
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
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.1.
|
4
|
+
version: 0.1.2
|
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-
|
11
|
+
date: 2015-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bogo
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- lib/grimoire/solver.rb
|
71
71
|
- lib/grimoire/system.rb
|
72
72
|
- lib/grimoire/unit.rb
|
73
|
+
- lib/grimoire/unit_score_keeper.rb
|
73
74
|
- lib/grimoire/utility.rb
|
74
75
|
- lib/grimoire/version.rb
|
75
76
|
homepage: https://github.com/spox/grimoire
|