taka_tic_tac_toe 1.2.0 → 1.3.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.
@@ -1,4 +1,4 @@
1
- require 'taka_tic_tac_toe/player'
1
+ require 'taka_tic_tac_toe/computer_factory'
2
2
  require 'taka_tic_tac_toe/board'
3
3
  require 'taka_tic_tac_toe/human'
4
4
  require 'taka_tic_tac_toe/computer'
@@ -25,7 +25,7 @@ module TakaTicTacToe
25
25
 
26
26
  mark = color == 1 ? @mark : @opponent_mark
27
27
 
28
- return check_game_state(board, (mark)) if board.has_winner || board.is_tie || depth == 3
28
+ return check_game_state(board, (mark)) if board.has_winner || board.is_tie || depth == 4
29
29
 
30
30
  board.empty_slots.each do |slots|
31
31
  board.set_move(mark, slots)
@@ -1,7 +1,7 @@
1
1
  module TakaTicTacToe
2
2
  class Computer
3
3
  attr_accessor :mark
4
- attr_reader :difficulty
4
+ attr_reader :difficulty, :opponent_mark
5
5
 
6
6
  def initialize(mark, opponent_mark)
7
7
  @mark = mark
@@ -0,0 +1,15 @@
1
+ module TakaTicTacToe
2
+ class PlayerFactory
3
+ def create(input)
4
+ if input[:type] == :computer
5
+ player = Computer.new(input[:mark], input[:opponent_mark])
6
+ player.difficulty = input[:difficulty]
7
+ elsif input[:type] == :human
8
+ player = Human.new(input[:mark])
9
+ else
10
+ raise "unknown player type"
11
+ end
12
+ player
13
+ end
14
+ end
15
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taka_tic_tac_toe
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-19 00:00:00.000000000 Z
12
+ date: 2013-04-29 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: tic tac toe engine
15
15
  email: tak.yuki@gmail.com
@@ -24,8 +24,8 @@ files:
24
24
  - lib/taka_tic_tac_toe/ai_difficulty/medium_ai.rb
25
25
  - lib/taka_tic_tac_toe/board.rb
26
26
  - lib/taka_tic_tac_toe/computer.rb
27
+ - lib/taka_tic_tac_toe/computer_factory.rb
27
28
  - lib/taka_tic_tac_toe/human.rb
28
- - lib/taka_tic_tac_toe/player.rb
29
29
  - lib/taka_tic_tac_toe.rb
30
30
  homepage:
31
31
  licenses: []
@@ -1,6 +0,0 @@
1
- class Player
2
- attr_reader :mark
3
- def initialize(mark)
4
- @mark = mark
5
- end
6
- end