class FifteenPuzzleSolver::Algorithm

Attributes

depth[R]
elapsed_time[R]
max_depth[R]
processed_nodes[R]
solution[R]
status[R]
visited_nodes[R]

Public Class Methods

new(board, acronym) click to toggle source
# File lib/fifteen_puzzle_solver/algorithm.rb, line 6
def initialize(board, acronym)
  @board = board
  @acronym = acronym
  @status = "ready"
  @depth = 0
  @max_depth = 0
  @explored = Set.new
end

Protected Instance Methods

save() click to toggle source
# File lib/fifteen_puzzle_solver/algorithm.rb, line 21
def save
  @elapsed_time = clock_time - @start_time
  @status = "failed" unless @status == "solved"
  @visited_nodes = @explored.count
  @processed_nodes = @frontier.length
  @explored.clear
end
start() click to toggle source
# File lib/fifteen_puzzle_solver/algorithm.rb, line 17
def start
  @start_time = clock_time
end

Private Instance Methods

clock_time() click to toggle source
# File lib/fifteen_puzzle_solver/algorithm.rb, line 31
def clock_time
  Process.clock_gettime(Process::CLOCK_MONOTONIC)
end