class Theseus::Algorithms::Base

A minimal abstract superclass for maze algorithms to descend from, mostly as a helper to provide some basic, common functionality.

Attributes

maze[R]

The maze object that the algorithm will operate on.

Public Class Methods

new(maze, options={}) click to toggle source

Create a new algorithm object that will operate on the given maze.

# File lib/theseus/algorithms/base.rb, line 12
def initialize(maze, options={})
  @maze = maze
  @pending = true
end

Public Instance Methods

pending?() click to toggle source

Returns true if the algorithm has not yet completed.

# File lib/theseus/algorithms/base.rb, line 18
def pending?
  @pending
end
step() click to toggle source

Execute a single step of the algorithm. Return true if the algorithm is still pending, or false if it has completed.

# File lib/theseus/algorithms/base.rb, line 25
def step
  return false unless pending?
  do_step
end