Class: PuzzleGenerator::ChainedMap

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

Overview

  1. put a chain

  2. destroy a chain by chain

    1. choose a position by last map

    1. choose a direct from 3 direct (memo p+d)

    1. check if the position + direct is ok? ok pass, failed choose again

    1. goto 2

Instance Attribute Summary collapse

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(option = {}) ⇒ ChainedMap

Returns a new instance of ChainedMap.



24
25
26
27
28
29
30
# File 'lib/puzzle_generator/chained_map.rb', line 24

def initialize option = {}
  @option = DefaultOption.merge option
  raise_if_bad_argument
  init_map
  @result_map = begin  next_level until @maps.size >= @option[:level]; put_fire_point
                rescue GenerationFailed; $! end
end

Instance Attribute Details

#mapsObject (readonly)

Returns the value of attribute maps.



23
24
25
# File 'lib/puzzle_generator/chained_map.rb', line 23

def maps
  @maps
end

#optionObject (readonly)

Returns the value of attribute option.



23
24
25
# File 'lib/puzzle_generator/chained_map.rb', line 23

def option
  @option
end