elus 0.1.0

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.
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <a:clrMap xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/>
@@ -0,0 +1,6 @@
1
+ <xml xmlns:o="urn:schemas-microsoft-com:office:office">
2
+ <o:MainFile HRef="../user_stories.htm"/>
3
+ <o:File HRef="themedata.thmx"/>
4
+ <o:File HRef="colorschememapping.xml"/>
5
+ <o:File HRef="filelist.xml"/>
6
+ </xml>
@@ -0,0 +1,91 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{elus}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["arvicco"]
12
+ s.date = %q{2010-03-11}
13
+ s.default_executable = %q{elus}
14
+ s.description = %q{This is a support tool for winning SpaceRangers:Elus}
15
+ s.email = %q{arvitallian@gmail.com}
16
+ s.executables = ["elus"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/elus",
29
+ "doc/dev_plan.htm",
30
+ "doc/dev_plan_files/colorschememapping.xml",
31
+ "doc/dev_plan_files/filelist.xml",
32
+ "doc/dev_plan_files/themedata.thmx",
33
+ "doc/user_stories.htm",
34
+ "doc/user_stories_files/colorschememapping.xml",
35
+ "doc/user_stories_files/filelist.xml",
36
+ "doc/user_stories_files/themedata.thmx",
37
+ "elus.gemspec",
38
+ "features/gamer_inputs_state.feature",
39
+ "features/gamer_starts_solver.feature",
40
+ "features/gamer_updates_state.feature",
41
+ "features/solver_shows_hints.feature",
42
+ "features/step_definitions/elus_steps.rb",
43
+ "features/support/env.rb",
44
+ "features/support/stats.rb",
45
+ "lib/elus.rb",
46
+ "lib/elus/game.rb",
47
+ "lib/elus/generator.rb",
48
+ "lib/elus/piece.rb",
49
+ "lib/elus/rule.rb",
50
+ "lib/elus/solver.rb",
51
+ "spec/cucumber/stats_spec.rb",
52
+ "spec/elus/game_spec.rb",
53
+ "spec/elus/generator_spec.rb",
54
+ "spec/elus/piece_spec.rb",
55
+ "spec/elus/rule_spec.rb",
56
+ "spec/elus/solver_spec.rb",
57
+ "spec/spec.opts",
58
+ "spec/spec_helper.rb"
59
+ ]
60
+ s.homepage = %q{http://github.com/arvicco/elus}
61
+ s.rdoc_options = ["--charset=UTF-8"]
62
+ s.require_paths = ["lib"]
63
+ s.rubygems_version = %q{1.3.5}
64
+ s.summary = %q{This is a support tool for winning SpaceRangers:Elus}
65
+ s.test_files = [
66
+ "spec/cucumber/stats_spec.rb",
67
+ "spec/elus/game_spec.rb",
68
+ "spec/elus/generator_spec.rb",
69
+ "spec/elus/piece_spec.rb",
70
+ "spec/elus/rule_spec.rb",
71
+ "spec/elus/solver_spec.rb",
72
+ "spec/spec_helper.rb"
73
+ ]
74
+
75
+ if s.respond_to? :specification_version then
76
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
77
+ s.specification_version = 3
78
+
79
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
80
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
81
+ s.add_development_dependency(%q<cucumber>, [">= 0"])
82
+ else
83
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
84
+ s.add_dependency(%q<cucumber>, [">= 0"])
85
+ end
86
+ else
87
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
88
+ s.add_dependency(%q<cucumber>, [">= 0"])
89
+ end
90
+ end
91
+
@@ -0,0 +1,135 @@
1
+ Feature: Gamer inputs Game state
2
+
3
+ In order to get help with specific Elus game,
4
+ as Gamer, I want to input Game state
5
+
6
+ Description: Gamer enters 3-char sequences representing 3 free Pieces.
7
+ If the Game just started, he is then prompted for 3 3-char sequences representing Pieces already on the Board.
8
+
9
+ Pieces have 3 characteristics: Size: BIG/SMALL, Color: YELLOW/GREEN, Type: DIAMOND/CIRCLE
10
+ Gamer's input will be in a form BYR, SGC, etc
11
+
12
+ Scenario: every correct code results in correct feedback / game state
13
+ Given new Game just started
14
+ When I run solver 2,000 times and use 6 correct codes to input state
15
+ Then I should see all the correct feedback, piece names and game states
16
+
17
+ Scenario Outline: every correct code results in correct feedback and game state
18
+ Given new Game just started
19
+ When I input code <code>
20
+ Then I should see "You entered Free Piece (1): <piece>"
21
+
22
+ Examples: Big Yellow Diamond
23
+ | code | piece |
24
+ | BYR | Big Yellow Diamond |
25
+ | BYD | Big Yellow Diamond |
26
+ | bYR | Big Yellow Diamond |
27
+ | ByR | Big Yellow Diamond |
28
+ | BYr | Big Yellow Diamond |
29
+ | byR | Big Yellow Diamond |
30
+ | bYr | Big Yellow Diamond |
31
+ | byr | Big Yellow Diamond |
32
+ | byd | Big Yellow Diamond |
33
+ | 111 | Big Yellow Diamond |
34
+ | bdy | Big Yellow Diamond |
35
+ | dyb | Big Yellow Diamond |
36
+ | d y b | Big Yellow Diamond |
37
+ | dby | Big Yellow Diamond |
38
+ | ybd | Big Yellow Diamond |
39
+ | ddddyb | Big Yellow Diamond |
40
+ | dyybb | Big Yellow Diamond |
41
+ | dxbyxd | Big Yellow Diamond |
42
+ | by1 | Big Yellow Diamond |
43
+
44
+ Examples: Small Yellow Diamond
45
+ | code | piece |
46
+ | SYR | Small Yellow Diamond|
47
+ | SYD | Small Yellow Diamond|
48
+ | syr | Small Yellow Diamond|
49
+ | syd | Small Yellow Diamond|
50
+ | 011 | Small Yellow Diamond|
51
+ | dys | Small Yellow Diamond|
52
+
53
+ Examples: Big Green Diamond
54
+ | code | piece |
55
+ | BGR | Big Green Diamond |
56
+ | BGD | Big Green Diamond |
57
+ | bgr | Big Green Diamond |
58
+ | bgd | Big Green Diamond |
59
+ | BgR | Big Green Diamond |
60
+ | 101 | Big Green Diamond |
61
+
62
+ Examples: Small Green Diamond
63
+ | code | piece |
64
+ | SGR | Small Green Diamond |
65
+ | SGD | Small Green Diamond |
66
+ | sgd | Small Green Diamond |
67
+ | 001 | Small Green Diamond |
68
+
69
+ Examples: Big Yellow Circle
70
+ | code | piece |
71
+ | BYC | Big Yellow Circle |
72
+ | byc | Big Yellow Circle |
73
+ | byC | Big Yellow Circle |
74
+ | bYC | Big Yellow Circle |
75
+ | bYc | Big Yellow Circle |
76
+ | Byc | Big Yellow Circle |
77
+ | ByC | Big Yellow Circle |
78
+ | BYC | Big Yellow Circle |
79
+ | BYc | Big Yellow Circle |
80
+ | 110 | Big Yellow Circle |
81
+
82
+ Examples: Small Yellow Diamond
83
+ | code | piece |
84
+ | SYC | Small Yellow Circle |
85
+ | syc | Small Yellow Circle |
86
+ | 010 | Small Yellow Circle |
87
+
88
+ Examples: Big Green Circle
89
+ | code | piece |
90
+ | BGC | Big Green Circle |
91
+ | bgc | Big Green Circle |
92
+ | 100 | Big Green Circle |
93
+
94
+ Examples: Small Green Circle
95
+ | code | piece |
96
+ | SGC | Small Green Circle |
97
+ | sgc | Small Green Circle |
98
+ | 000 | Small Green Circle |
99
+
100
+ Scenario Outline: wrong codes results in error message
101
+ Given new Game just started
102
+ When I input code <code>
103
+ Then I should see "Invalid code: <code>"
104
+
105
+ Examples: Ambiguous codes
106
+ | code |
107
+ | BSYR |
108
+ | BYgD |
109
+ | bYRc |
110
+ | Bydc |
111
+ | BsYgr |
112
+ | bygRc |
113
+ | bsYrc |
114
+ | bsygcr |
115
+
116
+ Examples: Not enough meaningful codes
117
+ | code |
118
+ | _ |
119
+ | !@# |
120
+ | B |
121
+ | gb |
122
+ | gr |
123
+ | sca |
124
+ | bgt |
125
+ | thd |
126
+
127
+ Examples: Numeric code errors (not enough, too much, wrong numbers)
128
+ | code |
129
+ | 0 |
130
+ | 1 |
131
+ | 01 |
132
+ | 11 |
133
+ | 1111 |
134
+ | 112 |
135
+ | 101231|
@@ -0,0 +1,13 @@
1
+ Feature: Gamer starts Solver
2
+
3
+ In order to win multiple Elus games,
4
+ as Gamer, I want to start Solver
5
+
6
+ Description: Gamer opens up a shell, types a command, and sees a welcome message and a prompt to input Game state.
7
+
8
+ Scenario: start Solver
9
+ Given I have not started yet
10
+ When I start Solver
11
+ Then I should see "Welcome to Elus Solver!"
12
+ And I should see "Enter Game state:"
13
+
@@ -0,0 +1,27 @@
1
+ Feature: Gamer updates state
2
+
3
+ In order to get relevant help as the Elus game progress,
4
+ as Gamer, I want to update Game state, making moves and reporting its results
5
+
6
+ Description: In response to "Please make your move:" prompt, Gamer enters 3-char code of the
7
+ Piece he is going to move (it should be one of 3 free Pieces). Gamer then gets feedback
8
+ either confirming the move or error message and prompt for the correct move. Once the move
9
+ is confirmed, Gamer is asked for move result (was the move right or wrong) and a new set of
10
+ free Game pieces if the result was right.
11
+
12
+ Scenario Outline: Gamer makes moves
13
+ Given Elus Game state is <state>
14
+ And Game started with <generator>
15
+ And Game state inputed
16
+ When I move <piece>
17
+ Then I should see "<feedback>"
18
+ And I should see "<next prompt>"
19
+
20
+ Examples:
21
+ | state | generator | piece | feedback | next prompt |
22
+ | BGC sgd syc BYD SYD BGD | Turn1Generator | SGD | You moved: Small Green Diamond | Was the move right(Y/N)?:|
23
+ | BGC sgd syc BYD SYD BGD | Turn1Generator | BGC | You moved: Big Green Circle | Was the move right(Y/N)?:|
24
+ | BGC sgd syc BYD SYD BGD | Turn1Generator | SYC | You moved: Small Yellow Circle | Was the move right(Y/N)?:|
25
+ | BGC sgd syc BYD SYD BGD | Turn1Generator | | Wrong move (no piece given) | Make your move: |
26
+ | BGC sgd syc BYD SYD BGD | Turn1Generator | SYD | Wrong move (not in free set): Small Yellow Diamond | Make your move: |
27
+
@@ -0,0 +1,36 @@
1
+ Feature: Solver shows hints
2
+
3
+ In order to get some help with Elus game
4
+ as Gamer, I want the Solver to show hints
5
+
6
+ Description: Once the Gamer inputs/updates valid Elus Game state,
7
+ Solver tries to figure out WHAT Rules may be possible under current Game state,
8
+ produces hints regarding possible rules and next moves by the Gamer and displays hints to the Gamer.
9
+
10
+ Scenario Outline: Solver shows hints after initial Game state input
11
+ Given Elus Game state is <state>
12
+ And Game started with <generator>
13
+ When I input Game state and prepare to move
14
+ Then I should see "<moves>"
15
+ And I should see "<rules>"
16
+
17
+ Examples: Invalid Game states:
18
+ | generator | state | moves | rules |
19
+ | EmptyGenerator | BYD BYD BYD BYD BYD BYD | Moves(0): | Rules(0): |
20
+ | Turn1Generator | BYD BYD BYD BYD BYD BYD | Moves(0): | Rules(0): |
21
+ | Turn2Generator | BYD BYD BYD BYD BYD BYD | Moves(0): | Rules(0): |
22
+ | Turn3Generator | BYD BYD BYD BYD BYD BYD | Moves(0): | Rules(0): |
23
+
24
+ Examples: Valid Game states:
25
+ | generator | state | moves | rules |
26
+ | Turn1Generator | BGC sgd syc BYD SYD BGD | Moves(1): | Rules(2): |
27
+
28
+ Scenario Outline: Solver shows hints after Gamer makes his move state input
29
+ Given Elus Game state is <code1>,<code2>,<code3>,<code4>,<code5>,<code6>
30
+ And Game started with <generator>
31
+ And initial Game state was already input
32
+ When I move this <piece>
33
+ Then I should see "<moves>"
34
+ And I should see "<rules>"
35
+
36
+
@@ -0,0 +1,116 @@
1
+ def stdout
2
+ @stdout ||= StringIO.new # STDOUT is an instance of IO. The StringIO object is very much like an IO object.
3
+ end
4
+
5
+ def stdin(input=nil)
6
+ @stdin ||= StringIO.new # STDIN is an instance of IO. The StringIO object is very much like an IO object.
7
+ @stdin.reopen input if input
8
+ @stdin
9
+ end
10
+
11
+ def solver
12
+ @solver ||= Elus::Solver.new(stdin, stdout) # Elus::Solver expects STDOUT, but we're giving it our StringIO @stdout instead
13
+ end
14
+
15
+ def solver_restart_and_input(input_codes)
16
+ @stdin = StringIO.new
17
+ @stdout = StringIO.new
18
+ stdin input_codes.join("\n")+"\n\n"
19
+ @solver = Elus::Solver.new(stdin, stdout)
20
+ solver.start generator
21
+ solver.input_state
22
+ end
23
+
24
+ def generator
25
+ @generator ||= stub('generator', :generate_rules => [])
26
+ end
27
+
28
+ def fixnum_from(string)
29
+ string.scan(/\d/).join.to_i
30
+ end
31
+
32
+ def messages_should_include(message)
33
+ @stdout.string.split("\n" ).should include(message)
34
+ end
35
+
36
+ def messages_include?(message)
37
+ @stdout.string.split("\n").include?(message)
38
+ end
39
+
40
+ def outputs_count(string, options={})
41
+ pattern = Regexp.new(options[:regex]? string : Regexp.escape(string))
42
+ @stdout.string.scan(pattern).size
43
+ end
44
+
45
+ def outputs_count_should_be_correct_for input_codes
46
+ # For each unique name corresponding to one of the input_codes
47
+ input_codes.map {|code| @code_names[code]}.uniq.each do |name|
48
+ repeats = input_codes.count {|code| @code_names[code]==name}
49
+ name_feedback = Regexp.escape('You entered ') + '.*' + Regexp.escape(": #{name}")
50
+ outputs_count(name_feedback, :regex => true).should == repeats
51
+ end
52
+ end
53
+
54
+ Given /^I have not started yet$/ do
55
+ end
56
+
57
+ When /^I start Solver$/ do
58
+ solver.start generator
59
+ end
60
+
61
+ Then /^I should see "([^\"]*)"$/ do |message|
62
+ messages_should_include(message)
63
+ end
64
+
65
+ Given /^new Game just started$/ do
66
+ solver.start generator
67
+ end
68
+
69
+ When /^I input code (.*)$/ do |code|
70
+ stdin "#{code}\n"+"BYR\n"*6+"\n"
71
+ solver.input_state
72
+ end
73
+
74
+ When /^I run solver (.*) times and use (.*) correct codes to input state/ do |times, num_codes|
75
+ @times = fixnum_from(times)
76
+ @num_codes = fixnum_from(num_codes)
77
+ @code_names = ElusTest::CODES
78
+ end
79
+
80
+ Then /^I should see all the correct feedback, piece names and game states$/ do
81
+ @times.times do
82
+ #@code_names.keys.combination(@num_codes) do |input_codes| # Takes too long to complete!
83
+ input_codes = Array.new(@num_codes) {|i| @code_names.keys[rand(@code_names.size)]}
84
+ solver_restart_and_input input_codes
85
+
86
+ outputs_count_should_be_correct_for input_codes
87
+ # outputs_count('Free:').should == 1
88
+ # outputs_count('Board:').should == 1
89
+ end
90
+
91
+ end
92
+
93
+ Given /^Elus Game state is (.*)$/ do |state|
94
+ stdin state.split(' ').join("\n")+"\n\n"
95
+ end
96
+
97
+ Given /^Game started with (.*)$/ do |gen_type|
98
+ Generator = Elus.const_get gen_type
99
+ solver.start Generator.new
100
+ end
101
+
102
+ When /^I input Game state and prepare to move$/ do
103
+ solver.input_state
104
+ @stdin.reopen "\n\n" # Inputing zero code for first move
105
+ solver.make_move
106
+ end
107
+
108
+ Given /^Game state inputed$/ do
109
+ solver.input_state
110
+ end
111
+
112
+ When /^I move (.*)$/ do |piece|
113
+ @stdin.reopen(piece+"\nY\nSYC\nSYD\nBYC\n")
114
+ solver.make_move
115
+ end
116
+
@@ -0,0 +1,5 @@
1
+ $LOAD_PATH << File.join(File.dirname(__FILE__),".." ,".." ,"lib" )
2
+ require 'spec/stubs/cucumber'
3
+ require File.join(File.dirname(__FILE__), "../../spec/spec_helper" )
4
+
5
+ require 'elus'
@@ -0,0 +1,32 @@
1
+ #module ElusTest
2
+ # class Stats
3
+ # def initialize(strings)
4
+ # @strings = strings
5
+ # @input_names.unique.each {|name| @counters[name]=0 }
6
+ ## @input_names = @input_codes.map {|code| codetable[code]}
7
+ ## @counters = {}
8
+ ##
9
+ ## @counters["Free:"] = 0
10
+ ## @counters["Board:"] = 0
11
+ # end
12
+ # end
13
+ #
14
+ # def puts(message)
15
+ # @counters.each do |name, counter|
16
+ #
17
+ # end
18
+ # end
19
+ #
20
+ # def count_for(code_or_name)
21
+ #
22
+ # end
23
+ #
24
+ # def correct?
25
+ # # @feedback.should == @runs
26
+ # # @piece.should == @runs
27
+ # # @free.should == @runs
28
+ # # @board.should == @runs
29
+ # end
30
+ #
31
+ # end
32
+ #end