Class: PuzzleGenerator::ColoredMap

Inherits:
Object
  • Object
show all
Includes:
DisplayMap, MapUtils
Defined in:
lib/puzzle_generator/colored_map.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes included from DisplayMap

#result_map

Instance Method Summary collapse

Methods included from DisplayMap

#display_map

Methods included from MapUtils

#check_answer_correctness, #check_down_chain, #check_left_chain, #check_right_chain, #check_up_chain, #combine_map, #destory_chains, #do_check_chain, #drop_blocks, #make_map_array, #resolve_map

Constructor Details

#initialize(chained_map, colors = (1..chained_map.option[:colors]).to_a) ⇒ ColoredMap

Returns a new instance of ColoredMap.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/puzzle_generator/colored_map.rb', line 7

def initialize chained_map, colors = (1..chained_map.option[:colors]).to_a
  @result_map = []
  @maps = []
  @chained_map = chained_map
  @option = @chained_map.option

  debug_init if PuzzleGenerator.debug

  chained_map.maps.each_with_index{ |map, index|
    @maps << map.clone_with_map{ |color|
      color == 0 ? 0 : colors[index % @option[:colors]]
    }
  }
  resolve_map
  @result_map = if check_no_invoke && strip_answer && check_answer_correctness
                  put_answer_back; @result_map
                else
                  GenerationFailed.new("ColoredMap: last result_map: #{@result_map.inspect}")
                end
end