linotype 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -61,7 +61,7 @@ module Linotype
61
61
 
62
62
  def test_potential_plays
63
63
  potential_moves = []
64
- potential_plays.each do |word_to_test|
64
+ remaining_plays.each do |word_to_test|
65
65
  every_play_for_word(word_to_test).each do |tiles|
66
66
  move = Move.new(self, @current_player, tiles)
67
67
  potential_moves << move
@@ -71,6 +71,14 @@ module Linotype
71
71
  potential_moves
72
72
  end
73
73
 
74
+ def previously_played_words
75
+ moves.collect(&:word)
76
+ end
77
+
78
+ def remaining_plays
79
+ potential_plays - previously_played_words
80
+ end
81
+
74
82
  def valid_potential_plays
75
83
  test_potential_plays.select { |potential_play| potential_play.valid? }
76
84
  end
@@ -132,6 +132,14 @@ module Linotype
132
132
  def prefix_of_previous_word?
133
133
  game.valid_moves.find { |move| move.word =~ /\A#{word}/ }
134
134
  end
135
-
135
+
136
+ def winning_move?
137
+ score[:remaining_uncovered_after] == 0 && score[:covered_after] >= game.all_tiles.count
138
+ end
139
+
140
+ def first_covered_corner?
141
+ score[:corners_defended_before] == 0 && score[:corners_defended_after] > 0
142
+ end
143
+
136
144
  end
137
145
  end
@@ -3,14 +3,14 @@ module Linotype
3
3
 
4
4
  EDGE_AND_CORNER = ->(move) do
5
5
  score = move.score[:covered] + move.score[:defended] + move.score[:edges] + move.score[:corners]
6
- score += 100000 if move.score[:remaining_uncovered_after] == 0
6
+ score += 100000 if move.winning_move?
7
7
  score
8
8
  end
9
9
 
10
10
  CORNER_LOVER = ->(move) do
11
11
  score = move.score[:covered] + move.score[:defended] + move.score[:edges] + move.score[:corners]
12
- score += 10 if (move.score[:corners_defended_before] == 0 && move.score[:corners_defended_after] > 0)
13
- score += 100000 if move.score[:remaining_uncovered_after] == 0
12
+ score += 10 if move.first_covered_corner?
13
+ score += 100000 if move.winning_move?
14
14
  score
15
15
  end
16
16
 
@@ -1,3 +1,3 @@
1
1
  module Linotype
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: linotype
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
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: 2012-10-31 00:00:00.000000000 Z
12
+ date: 2012-11-02 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! ' linotype implements that game mechanic of Letterpress for iOS by
15
15
  atebits software. The program was written to support the automation of letterpress