Class: GameOverChecker
- Inherits:
-
Object
- Object
- GameOverChecker
- Defined in:
- lib/threesmodel/game_over_checker.rb
Instance Method Summary collapse
- #game_over?(state) ⇒ Boolean
-
#initialize ⇒ GameOverChecker
constructor
A new instance of GameOverChecker.
Constructor Details
#initialize ⇒ GameOverChecker
Returns a new instance of GameOverChecker.
4 5 6 |
# File 'lib/threesmodel/game_over_checker.rb', line 4 def initialize @line_folder = LineFolder.new end |
Instance Method Details
#game_over?(state) ⇒ Boolean
8 9 10 11 12 13 14 15 16 |
# File 'lib/threesmodel/game_over_checker.rb', line 8 def game_over?(state) state.row_vectors.each {|row| if ((@line_folder.can_fold?(row.to_a)) or (@line_folder.can_fold?(row.to_a.reverse))) then return false end } state.column_vectors.each{|column| if ((@line_folder.can_fold?(column.to_a)) or (@line_folder.can_fold?(column.to_a.reverse))) then return false end } true end |