elus 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +30 -0
- data/Rakefile +57 -0
- data/VERSION +1 -0
- data/bin/elus +8 -0
- data/doc/dev_plan.htm +923 -0
- data/doc/dev_plan_files/colorschememapping.xml +2 -0
- data/doc/dev_plan_files/filelist.xml +6 -0
- data/doc/dev_plan_files/themedata.thmx +0 -0
- data/doc/user_stories.htm +959 -0
- data/doc/user_stories_files/colorschememapping.xml +2 -0
- data/doc/user_stories_files/filelist.xml +6 -0
- data/doc/user_stories_files/themedata.thmx +0 -0
- data/elus.gemspec +91 -0
- data/features/gamer_inputs_state.feature +135 -0
- data/features/gamer_starts_solver.feature +13 -0
- data/features/gamer_updates_state.feature +27 -0
- data/features/solver_shows_hints.feature +36 -0
- data/features/step_definitions/elus_steps.rb +116 -0
- data/features/support/env.rb +5 -0
- data/features/support/stats.rb +32 -0
- data/lib/elus.rb +5 -0
- data/lib/elus/game.rb +74 -0
- data/lib/elus/generator.rb +48 -0
- data/lib/elus/piece.rb +93 -0
- data/lib/elus/rule.rb +36 -0
- data/lib/elus/solver.rb +84 -0
- data/spec/cucumber/stats_spec.rb +13 -0
- data/spec/elus/game_spec.rb +116 -0
- data/spec/elus/generator_spec.rb +124 -0
- data/spec/elus/piece_spec.rb +190 -0
- data/spec/elus/rule_spec.rb +39 -0
- data/spec/elus/solver_spec.rb +203 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +198 -0
- metadata +117 -0
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,198 @@
|
|
1
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__),".." ,"lib" )
|
2
|
+
|
3
|
+
#require 'rubygems'
|
4
|
+
#require 'spec'
|
5
|
+
require 'elus'
|
6
|
+
|
7
|
+
module ElusTest
|
8
|
+
PIECE_CHARS = '01=!.'
|
9
|
+
NONDOT_CHARS = '01!='
|
10
|
+
|
11
|
+
def random_chars_twice(n=1, string=PIECE_CHARS)
|
12
|
+
chars = string.split(//)
|
13
|
+
n.times { yield chars.sample(3).join(''), chars.sample(3).join('') }
|
14
|
+
end
|
15
|
+
|
16
|
+
def all_chars(string=PIECE_CHARS)
|
17
|
+
chars = string.split(//)
|
18
|
+
chars.product(chars,chars).each {|code_chars| yield code_chars.join('') }
|
19
|
+
end
|
20
|
+
|
21
|
+
def all_chars_twice(string1=PIECE_CHARS, string2=string1)
|
22
|
+
all_chars(string1) {|code1| all_chars(string2) {|code2| yield code1, code2 } }
|
23
|
+
end
|
24
|
+
|
25
|
+
def permutate(string=NONDOT_CHARS)
|
26
|
+
string.split(//).product(['.'],['.']).each do |set|
|
27
|
+
set.permutation.to_a.uniq.each do |code_chars|
|
28
|
+
yield code_chars.join('')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def should_be_equal(p1, p2)
|
34
|
+
(p1 == p2).should be_true
|
35
|
+
(p1 >= p2).should be_true
|
36
|
+
(p1 <= p2).should be_true
|
37
|
+
(p1 > p2).should be_false
|
38
|
+
(p1 < p2).should be_false
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
BYD = 'Big Yellow Diamond'
|
44
|
+
WRONG_RULES = [
|
45
|
+
["B", 'BY', 'BSYC'],
|
46
|
+
['BYG', 'BYCD'],
|
47
|
+
['BGX', 'ZXC', 1],
|
48
|
+
['ZXAQWET1234567890', ''],
|
49
|
+
[1, 2],
|
50
|
+
[1, 2, 3],
|
51
|
+
['...', '..1', 3]
|
52
|
+
]
|
53
|
+
RULES = {
|
54
|
+
['...', '.!.'] => 'If last Piece is Any Piece, Different color Piece is next',
|
55
|
+
['...', '..='] => 'If last Piece is Any Piece, Same shape Piece is next',
|
56
|
+
['...', '1..'] => 'If last Piece is Any Piece, Big Piece is next',
|
57
|
+
['...', '.!1'] => 'If last Piece is Any Piece, Different color Diamond Piece is next',
|
58
|
+
['..1', '1..', '0..'] => 'If last Piece is Diamond Piece, Big Piece is next, otherwise Small Piece is next',
|
59
|
+
['1..', '.0.', '.1.'] => 'If last Piece is Big Piece, Green Piece is next, otherwise Yellow Piece is next',
|
60
|
+
['..1', '=..', '!..'] => 'If last Piece is Diamond Piece, Same size Piece is next, otherwise Different size Piece is next',
|
61
|
+
['.1.', '..!', '0..'] => 'If last Piece is Yellow Piece, Different shape Piece is next, otherwise Small Piece is next'
|
62
|
+
}
|
63
|
+
|
64
|
+
|
65
|
+
WRONG_CODES = ["B", 'BY', 'BSYC', 'BYG', 'BYCD', 'BGX', 'ZXC', 'ZXAQWET1234567890', " "]
|
66
|
+
|
67
|
+
SPECIAL_CODES = {
|
68
|
+
'...' => 'Any',
|
69
|
+
'1..' => 'Big',
|
70
|
+
'0..' => 'Small',
|
71
|
+
'.1.' => 'Yellow',
|
72
|
+
'.0.' => 'Green',
|
73
|
+
'..1' => 'Diamond',
|
74
|
+
'..0' => 'Circle',
|
75
|
+
'11.' => 'Big Yellow',
|
76
|
+
'10.' => 'Big Green',
|
77
|
+
'01.' => 'Small Yellow',
|
78
|
+
'00.' => 'Small Green',
|
79
|
+
'1.1' => 'Big Diamond',
|
80
|
+
'1.0' => 'Big Circle',
|
81
|
+
'0.1' => 'Small Diamond',
|
82
|
+
'0.0' => 'Small Circle',
|
83
|
+
'.11' => 'Yellow Diamond',
|
84
|
+
'.10' => 'Yellow Circle',
|
85
|
+
'.01' => 'Green Diamond',
|
86
|
+
'.00' => 'Green Circle',
|
87
|
+
'!..' => 'Different size',
|
88
|
+
'=..' => 'Same size',
|
89
|
+
'.!.' => 'Different color',
|
90
|
+
'.=.' => 'Same color',
|
91
|
+
'..!' => 'Different shape',
|
92
|
+
'..=' => 'Same shape',
|
93
|
+
'!!.' => 'Different size Different color',
|
94
|
+
'!=.' => 'Different size Same color',
|
95
|
+
'=!.' => 'Same size Different color',
|
96
|
+
'==.' => 'Same size Same color',
|
97
|
+
'!.!' => 'Different size Different shape',
|
98
|
+
'!.=' => 'Different size Same shape',
|
99
|
+
'=.!' => 'Same size Different shape',
|
100
|
+
'=.=' => 'Same size Same shape',
|
101
|
+
'.!!' => 'Different color Different shape',
|
102
|
+
'.!=' => 'Different color Same shape',
|
103
|
+
'.=!' => 'Same color Different shape',
|
104
|
+
'.==' => 'Same color Same shape',
|
105
|
+
'!!1' => 'Different size Different color Diamond',
|
106
|
+
'!=1' => 'Different size Same color Diamond',
|
107
|
+
'=!1' => 'Same size Different color Diamond',
|
108
|
+
'==1' => 'Same size Same color Diamond',
|
109
|
+
'!1!' => 'Different size Yellow Different shape',
|
110
|
+
'!1=' => 'Different size Yellow Same shape',
|
111
|
+
'=1!' => 'Same size Yellow Different shape',
|
112
|
+
'=1=' => 'Same size Yellow Same shape',
|
113
|
+
'1!!' => 'Big Different color Different shape',
|
114
|
+
'1!=' => 'Big Different color Same shape',
|
115
|
+
'1=!' => 'Big Same color Different shape',
|
116
|
+
'1==' => 'Big Same color Same shape',
|
117
|
+
'!!0' => 'Different size Different color Circle',
|
118
|
+
'!=0' => 'Different size Same color Circle',
|
119
|
+
'=!0' => 'Same size Different color Circle',
|
120
|
+
'==0' => 'Same size Same color Circle',
|
121
|
+
'!0!' => 'Different size Green Different shape',
|
122
|
+
'!0=' => 'Different size Green Same shape',
|
123
|
+
'=0!' => 'Same size Green Different shape',
|
124
|
+
'=0=' => 'Same size Green Same shape',
|
125
|
+
'0!!' => 'Small Different color Different shape',
|
126
|
+
'0!=' => 'Small Different color Same shape',
|
127
|
+
'0=!' => 'Small Same color Different shape',
|
128
|
+
'0==' => 'Small Same color Same shape',
|
129
|
+
'!!!' => 'All Different',
|
130
|
+
'===' => 'All Same',
|
131
|
+
'B!0' => 'Big Different color Circle',
|
132
|
+
'!g0' => 'Different size Green Circle',
|
133
|
+
'0!0' => 'Small Different color Circle',
|
134
|
+
'=10' => 'Same size Yellow Circle',
|
135
|
+
'!0d' => 'Different size Green Diamond',
|
136
|
+
'!00' => 'Different size Green Circle',
|
137
|
+
'=01' => 'Same size Green Diamond',
|
138
|
+
'=gc' => 'Same size Green Circle',
|
139
|
+
'0y!' => 'Small Yellow Different shape',
|
140
|
+
'00=' => 'Small Green Same shape',
|
141
|
+
'0Y!' => 'Small Yellow Different shape',
|
142
|
+
's1=' => 'Small Yellow Same shape',
|
143
|
+
}
|
144
|
+
CODES = {
|
145
|
+
"BYR"=>BYD,
|
146
|
+
"BYD"=>BYD,
|
147
|
+
"bYR"=>BYD,
|
148
|
+
"ByR"=>BYD,
|
149
|
+
"BYr"=>BYD,
|
150
|
+
"byR"=>BYD,
|
151
|
+
"bYr"=>BYD,
|
152
|
+
"byr"=>BYD,
|
153
|
+
"byd"=>BYD,
|
154
|
+
"111"=>BYD,
|
155
|
+
"bdy"=>BYD,
|
156
|
+
"B YD"=>BYD,
|
157
|
+
"dyb"=>BYD,
|
158
|
+
"bY R"=>BYD,
|
159
|
+
"B y R"=>BYD,
|
160
|
+
" b y R "=>BYD,
|
161
|
+
"bYr "=>BYD,
|
162
|
+
" byr"=>BYD,
|
163
|
+
"1 1 1"=>BYD,
|
164
|
+
"SYR"=>"Small Yellow Diamond",
|
165
|
+
"SYD"=>"Small Yellow Diamond",
|
166
|
+
"syr"=>"Small Yellow Diamond",
|
167
|
+
"syd"=>"Small Yellow Diamond",
|
168
|
+
"011"=>"Small Yellow Diamond",
|
169
|
+
"dys"=>"Small Yellow Diamond",
|
170
|
+
"BGR"=>"Big Green Diamond",
|
171
|
+
"BGD"=>"Big Green Diamond",
|
172
|
+
"bgr"=>"Big Green Diamond",
|
173
|
+
"bgd"=>"Big Green Diamond",
|
174
|
+
"BgR"=>"Big Green Diamond",
|
175
|
+
"101"=>"Big Green Diamond",
|
176
|
+
"SGR"=>"Small Green Diamond",
|
177
|
+
"SGD"=>"Small Green Diamond",
|
178
|
+
"sgd"=>"Small Green Diamond",
|
179
|
+
"001"=>"Small Green Diamond",
|
180
|
+
"BYC"=>"Big Yellow Circle",
|
181
|
+
"byc"=>"Big Yellow Circle",
|
182
|
+
"byC"=>"Big Yellow Circle",
|
183
|
+
"bYC"=>"Big Yellow Circle",
|
184
|
+
"bYc"=>"Big Yellow Circle",
|
185
|
+
"Byc"=>"Big Yellow Circle",
|
186
|
+
"ByC"=>"Big Yellow Circle",
|
187
|
+
"BYc"=>"Big Yellow Circle",
|
188
|
+
"110"=>"Big Yellow Circle",
|
189
|
+
"SYC"=>"Small Yellow Circle",
|
190
|
+
"syc"=>"Small Yellow Circle",
|
191
|
+
"010"=>"Small Yellow Circle",
|
192
|
+
"BGC"=>"Big Green Circle",
|
193
|
+
"bgc"=>"Big Green Circle",
|
194
|
+
"100"=>"Big Green Circle",
|
195
|
+
"SGC"=>"Small Green Circle",
|
196
|
+
"sgc"=>"Small Green Circle",
|
197
|
+
"000"=>"Small Green Circle" }
|
198
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: elus
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- arvicco
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-03-11 00:00:00 +03:00
|
13
|
+
default_executable: elus
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.9
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: cucumber
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
description: This is a support tool for winning SpaceRangers:Elus
|
36
|
+
email: arvitallian@gmail.com
|
37
|
+
executables:
|
38
|
+
- elus
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files:
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
|
+
files:
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- VERSION
|
51
|
+
- bin/elus
|
52
|
+
- doc/dev_plan.htm
|
53
|
+
- doc/dev_plan_files/colorschememapping.xml
|
54
|
+
- doc/dev_plan_files/filelist.xml
|
55
|
+
- doc/dev_plan_files/themedata.thmx
|
56
|
+
- doc/user_stories.htm
|
57
|
+
- doc/user_stories_files/colorschememapping.xml
|
58
|
+
- doc/user_stories_files/filelist.xml
|
59
|
+
- doc/user_stories_files/themedata.thmx
|
60
|
+
- elus.gemspec
|
61
|
+
- features/gamer_inputs_state.feature
|
62
|
+
- features/gamer_starts_solver.feature
|
63
|
+
- features/gamer_updates_state.feature
|
64
|
+
- features/solver_shows_hints.feature
|
65
|
+
- features/step_definitions/elus_steps.rb
|
66
|
+
- features/support/env.rb
|
67
|
+
- features/support/stats.rb
|
68
|
+
- lib/elus.rb
|
69
|
+
- lib/elus/game.rb
|
70
|
+
- lib/elus/generator.rb
|
71
|
+
- lib/elus/piece.rb
|
72
|
+
- lib/elus/rule.rb
|
73
|
+
- lib/elus/solver.rb
|
74
|
+
- spec/cucumber/stats_spec.rb
|
75
|
+
- spec/elus/game_spec.rb
|
76
|
+
- spec/elus/generator_spec.rb
|
77
|
+
- spec/elus/piece_spec.rb
|
78
|
+
- spec/elus/rule_spec.rb
|
79
|
+
- spec/elus/solver_spec.rb
|
80
|
+
- spec/spec.opts
|
81
|
+
- spec/spec_helper.rb
|
82
|
+
has_rdoc: true
|
83
|
+
homepage: http://github.com/arvicco/elus
|
84
|
+
licenses: []
|
85
|
+
|
86
|
+
post_install_message:
|
87
|
+
rdoc_options:
|
88
|
+
- --charset=UTF-8
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: "0"
|
96
|
+
version:
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: "0"
|
102
|
+
version:
|
103
|
+
requirements: []
|
104
|
+
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 1.3.5
|
107
|
+
signing_key:
|
108
|
+
specification_version: 3
|
109
|
+
summary: This is a support tool for winning SpaceRangers:Elus
|
110
|
+
test_files:
|
111
|
+
- spec/cucumber/stats_spec.rb
|
112
|
+
- spec/elus/game_spec.rb
|
113
|
+
- spec/elus/generator_spec.rb
|
114
|
+
- spec/elus/piece_spec.rb
|
115
|
+
- spec/elus/rule_spec.rb
|
116
|
+
- spec/elus/solver_spec.rb
|
117
|
+
- spec/spec_helper.rb
|