ttt_malisa 0.2.4 → 0.2.5
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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +1 -1
- data/lib/ttt_malisa/board.rb +1 -1
- data/lib/ttt_malisa/computer_player.rb +5 -10
- data/lib/ttt_malisa/game_factory.rb +2 -1
- data/lib/ttt_malisa/menu.rb +2 -1
- data/lib/ttt_malisa/version.rb +1 -1
- data/lib/ttt_malisa.rb +3 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 259f7d51cad882548f7f8bd1796d62b304853b6e1ef3959f9b917ccf6a16f363
|
4
|
+
data.tar.gz: 582a1e9402ca25b57f1aecdf6809f1edd5b7f355ff8ae8cde9a1f646183243d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 626fd824dd5f1b185d8ce4b42bf0b094a5c602a11077b9460d23b2ff6fa52b04b5b64c57d3f207c2098538634a2cb563ee52cfe8584f9bc1f1c7151db8bd3f8b
|
7
|
+
data.tar.gz: 3a3d4b16c885d6160c302c8fe5c9df660dd2a0247679de11f39aaba65e18b608f0a83098ee09d542839cf0274ea0944d96fe7756191ac82432d46e91fefe00ff
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/lib/ttt_malisa/board.rb
CHANGED
@@ -17,7 +17,7 @@ class Board
|
|
17
17
|
|
18
18
|
def available_moves
|
19
19
|
open_squares = []
|
20
|
-
@squares.each_with_index {|
|
20
|
+
@squares.each_with_index {|value, index| open_squares << index if value == ' '}
|
21
21
|
open_squares
|
22
22
|
end
|
23
23
|
|
@@ -9,20 +9,15 @@ class ComputerPlayer
|
|
9
9
|
|
10
10
|
def move
|
11
11
|
@display.make_move_message(@mark)
|
12
|
-
index = retrieve_computer_index
|
13
|
-
computer_is_thinking
|
14
|
-
@display.computer_move(index + 1)
|
15
|
-
@board.valid_move?(index) ? @board.mark(index, @mark) : move
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def computer_is_thinking
|
12
|
+
index = retrieve_computer_index(1)
|
21
13
|
@display.computer_thinking
|
22
14
|
sleep 1
|
15
|
+
@display.computer_move(index + 1)
|
16
|
+
@board.valid_move?(index) ? @board.mark(index, @mark) : move
|
23
17
|
end
|
24
18
|
|
25
|
-
def retrieve_computer_index
|
19
|
+
def retrieve_computer_index(seed)
|
20
|
+
srand(seed)
|
26
21
|
available_move = @board.available_moves
|
27
22
|
available_move[0]
|
28
23
|
end
|
data/lib/ttt_malisa/menu.rb
CHANGED
data/lib/ttt_malisa/version.rb
CHANGED
data/lib/ttt_malisa.rb
CHANGED
@@ -1,16 +1,6 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
|
4
|
-
require_relative './ttt_malisa/board'
|
5
|
-
require_relative './ttt_malisa/computer_player'
|
6
|
-
require_relative './ttt_malisa/console'
|
7
|
-
require_relative './ttt_malisa/display'
|
8
|
-
require_relative './ttt_malisa/dummy'
|
9
|
-
require_relative './ttt_malisa/game_factory'
|
10
|
-
require_relative './ttt_malisa/game'
|
11
|
-
require_relative './ttt_malisa/human_player'
|
12
|
-
require_relative './ttt_malisa/menu'
|
13
|
-
require_relative './ttt_malisa/rules'
|
1
|
+
require 'ttt_malisa/version'
|
2
|
+
require 'require_all'
|
3
|
+
require_all 'lib/ttt_malisa'
|
14
4
|
|
15
5
|
module TttMalisa
|
16
6
|
class Error < StandardError; end
|