threesmodel 0.0.3

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,38 @@
1
+ require_relative "../lib/next_number_determinator"
2
+ require_relative "custom_matchers"
3
+
4
+ describe NextNumberDeterminator do
5
+
6
+ include CustomMatchers
7
+
8
+ before(:each) do
9
+ @next_number_determinator = NextNumberDeterminator.new
10
+ end
11
+
12
+
13
+ it "allows ones, twos and threes when game board is in initial state" do
14
+ expect(@next_number_determinator.select_number(
15
+ Matrix.rows([[1,3,0,0],
16
+ [2,0,3,2],
17
+ [0,0,3,1],
18
+ [2,0,0,3]]))).to be_one_of([1, 2, 3])
19
+ end
20
+
21
+ it "can determine the highest number on the board" do
22
+ expect(@next_number_determinator.highest_number(
23
+ Matrix.rows([[ 1,48,0,0],
24
+ [24, 0,3,2],
25
+ [ 0, 0,3,1],
26
+ [ 2, 0,0,3]]))).to eq(48)
27
+ end
28
+
29
+
30
+ it "allows all but the two highest numbers for boards with higher numbers" do
31
+ expect(@next_number_determinator.select_number(
32
+ Matrix.rows([[ 1,48,0,0],
33
+ [24, 0,3,2],
34
+ [ 0, 0,3,1],
35
+ [ 2, 0,0,3]]))).to be_one_of([1, 2, 3, 6, 12])
36
+ end
37
+
38
+ end
@@ -0,0 +1,28 @@
1
+ require_relative "../lib/next_number_positioner"
2
+ require_relative "custom_matchers"
3
+
4
+ describe NextNumberPositioner do
5
+
6
+ include CustomMatchers
7
+
8
+ before(:each) do
9
+ @number_adder = NextNumberPositioner.new
10
+ end
11
+
12
+ it "will always add to the one cell provided" do
13
+ expect(@number_adder.select_position([[0,1]])).to eq([0,1])
14
+ end
15
+
16
+ it "will always return one element when given more candidates" do
17
+ #Since it returns one of the encapsulated lists the size should be 2
18
+ expect(@number_adder.select_position([[0,0], [0,1]]).size).to eq(2)
19
+ expect(@number_adder.select_position([[0,0], [0,1], [0,2]]).size).to eq(2)
20
+ expect(@number_adder.select_position([[0,0], [0,1], [0,2], [0,3]]).size).to eq(2)
21
+ end
22
+
23
+ it "will always return a valid candidate" do
24
+ expect(@number_adder.select_position([[0,0], [0,1]])).to be_one_of([[0,0], [0,1]])
25
+ expect(@number_adder.select_position([[0,0], [0,1], [0,2]])).to be_one_of([[0,0], [0,1], [0,2]])
26
+ expect(@number_adder.select_position([[0,0], [0,1], [0,2], [0,3]])).to be_one_of([[0,0], [0,1], [0,2], [0,3]])
27
+ end
28
+ end
@@ -0,0 +1,17 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'threesmodel/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "threesmodel"
8
+ spec.version = Threesmodel::VERSION
9
+ spec.authors = ["Måns Sandström"]
10
+ spec.email = ["mans.sandstrom@gmail.com"]
11
+ spec.description = %q{A stab at implementing the game logic for the game threes, eventually making it scriptable for a bot.}
12
+ spec.summary = %q{An API for something that resembles the game threes}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.14"
22
+ spec.add_development_dependency "rake", "~> 11.2"
23
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: threesmodel
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Måns Sandström
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-03-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '11.2'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '11.2'
41
+ description: A stab at implementing the game logic for the game threes, eventually
42
+ making it scriptable for a bot.
43
+ email:
44
+ - mans.sandstrom@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - ".rspec"
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - features/basic_folding.feature
56
+ - features/basic_summing.feature
57
+ - features/game_over.feature
58
+ - features/scoring.feature
59
+ - features/start_game.feature
60
+ - features/steps/basic_steps.rb
61
+ - features/steps/game_over_steps.rb
62
+ - features/steps/game_play_steps.rb
63
+ - lib/candidate_extractor.rb
64
+ - lib/candidate_translator.rb
65
+ - lib/game_board_folder.rb
66
+ - lib/game_creator.rb
67
+ - lib/game_over_checker.rb
68
+ - lib/line_folder.rb
69
+ - lib/next_number_determinator.rb
70
+ - lib/next_number_positioner.rb
71
+ - lib/score_calculator.rb
72
+ - lib/threesmodel.rb
73
+ - lib/threesmodel/version.rb
74
+ - spec/candidate_extraction_spec.rb
75
+ - spec/candidate_translator_spec.rb
76
+ - spec/custom_matchers.rb
77
+ - spec/game_board_folder_spec.rb
78
+ - spec/game_creator_spec.rb
79
+ - spec/line_folder_spec.rb
80
+ - spec/next_number_determination_spec.rb
81
+ - spec/next_number_positioner_spec.rb
82
+ - spec/spec_helper.rb
83
+ - threesmodel.gemspec
84
+ homepage: ''
85
+ licenses:
86
+ - MIT
87
+ metadata: {}
88
+ post_install_message:
89
+ rdoc_options: []
90
+ require_paths:
91
+ - lib
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project:
104
+ rubygems_version: 2.5.1
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: An API for something that resembles the game threes
108
+ test_files:
109
+ - features/basic_folding.feature
110
+ - features/basic_summing.feature
111
+ - features/game_over.feature
112
+ - features/scoring.feature
113
+ - features/start_game.feature
114
+ - features/steps/basic_steps.rb
115
+ - features/steps/game_over_steps.rb
116
+ - features/steps/game_play_steps.rb
117
+ - spec/candidate_extraction_spec.rb
118
+ - spec/candidate_translator_spec.rb
119
+ - spec/custom_matchers.rb
120
+ - spec/game_board_folder_spec.rb
121
+ - spec/game_creator_spec.rb
122
+ - spec/line_folder_spec.rb
123
+ - spec/next_number_determination_spec.rb
124
+ - spec/next_number_positioner_spec.rb
125
+ - spec/spec_helper.rb