Class: Theseus::UpsilonMaze

Inherits:
Maze
  • Object
show all
Defined in:
lib/theseus/upsilon_maze.rb

Overview

An upsilon maze is one in which the field is tesselated into octogons and squares:

 _   _   _   _
/ \_/ \_/ \_/ \
| |_| |_| |_| |
\_/ \_/ \_/ \_/
|_| |_| |_| |_|
/ \_/ \_/ \_/ \
| |_| |_| |_| |
\_/ \_/ \_/ \_/

Upsilon mazes in Theseus support weaving, but not symmetry (yet).

maze = Theseus::UpsilonMaze.generate(width: 10)
puts maze

Constant Summary

Constants inherited from Maze

Maze::E, Maze::N, Maze::NE, Maze::NW, Maze::PRIMARY, Maze::RESERVED, Maze::S, Maze::SE, Maze::SW, Maze::UNDER, Maze::UNDER_SHIFT, Maze::W

Instance Attribute Summary

Attributes inherited from Maze

#algorithm, #braid, #entrance, #exit, #height, #mask, #randomness, #symmetry, #weave, #width, #wrap

Instance Method Summary collapse

Methods inherited from Maze

#[], #[]=, #add_opening_from, #adjacent_point, #apply_move_at, #clockwise, #counter_clockwise, #dead?, #dead_ends, #dx, #dy, #finish, generate, #generate!, #generated?, #hmirror, #initialize, #inspect, #move, #new_path, #new_solver, #opposite, #relative_direction, #row_length, #solve, #sparsify!, #start, #step, #to, #to_s, #type, #valid?, #vmirror, #weave_allowed?, #wrap_x?, #wrap_y?

Constructor Details

This class inherits a constructor from Theseus::Maze

Instance Method Details

#perform_weave(from_x, from_y, to_x, to_y, direction) ⇒ Object

:nodoc:



29
30
31
32
33
34
35
# File 'lib/theseus/upsilon_maze.rb', line 29

def perform_weave(from_x, from_y, to_x, to_y, direction) #:nodoc:
  apply_move_at(to_x, to_y, direction << UNDER_SHIFT)
  apply_move_at(to_x, to_y, opposite(direction) << UNDER_SHIFT)

  nx, ny = move(to_x, to_y, direction)
  [nx, ny, direction]
end

#potential_exits_at(x, y) ⇒ Object

:nodoc:



21
22
23
24
25
26
27
# File 'lib/theseus/upsilon_maze.rb', line 21

def potential_exits_at(x, y) #:nodoc:
  if (x+y) % 2 == 0 # octogon
    [N, S, E, W, NW, NE, SW, SE]
  else # square
    [N, S, E, W]
  end
end