taka_tic_tac_toe 1.0.0 → 1.2.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,16 +1,23 @@
1
1
  module TakaTicTacToe
2
2
  class Board
3
- attr_reader :slots
3
+ attr_accessor :slots
4
4
 
5
5
  WinComb = [[0,1,2],[3,4,5],[6,7,8],
6
6
  [0,3,6],[1,4,7],[2,5,8],
7
7
  [0,4,8],[2,4,6]]
8
+
8
9
  def initialize
9
10
  @slots = %w[1 2 3 4 5 6 7 8 9]
10
11
  end
11
12
 
12
- def set_board(board)
13
- @slots = board
13
+ def to_s
14
+ @slots.join
15
+ end
16
+
17
+ def self.parse(board)
18
+ parsed_board = self.new
19
+ parsed_board.slots = board.split('')
20
+ parsed_board
14
21
  end
15
22
 
16
23
  def get(index)
@@ -1,5 +1,4 @@
1
1
  require 'taka_tic_tac_toe/player'
2
- require 'taka_tic_tac_toe/game'
3
2
  require 'taka_tic_tac_toe/board'
4
3
  require 'taka_tic_tac_toe/human'
5
4
  require 'taka_tic_tac_toe/computer'
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.0.0
4
+ version: 1.2.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-18 00:00:00.000000000 Z
12
+ date: 2013-04-19 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: tic tac toe engine
15
15
  email: tak.yuki@gmail.com
@@ -24,7 +24,6 @@ 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/game.rb
28
27
  - lib/taka_tic_tac_toe/human.rb
29
28
  - lib/taka_tic_tac_toe/player.rb
30
29
  - lib/taka_tic_tac_toe.rb
@@ -1,42 +0,0 @@
1
- module TakaTicTacToe
2
- class Game
3
-
4
- attr_accessor :human, :board, :computer
5
-
6
-
7
- def initialize
8
- @human = Human.new('X')
9
- @board = Board.new
10
- @computer = Computer.new('O', @human.mark)
11
- end
12
-
13
- def make_moves(move)
14
- choose_move(get_human_mark, move)
15
- choose_move(get_computer_mark, computer_move) if !is_over?
16
- end
17
-
18
- def reset_board
19
- @board.reset
20
- end
21
-
22
- def get_human_mark
23
- @human.mark
24
- end
25
-
26
- def computer_move
27
- @computer.make_move(@board)
28
- end
29
-
30
- def get_computer_mark
31
- @computer.mark
32
- end
33
-
34
- def is_over?
35
- @board.is_tie || @board.has_winner
36
- end
37
-
38
- def choose_move(mark, index)
39
- @board.set_move(mark, index)
40
- end
41
- end
42
- end