AStar_class: Convenience class for running A* algorithm.

Description Usage Format Examples

Description

Has methods for all function arguments of astar.

Usage

1

Format

An object of class R6ClassGenerator of length 24.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
 nodes <- list(
   A = c(B = 100, C = 20),
   C = c(D = 20),
   D = c(B = 20)
 )
 Searcher <- R6::R6Class(
   "Searcher",
   inherit = AStar,
   public = list(
     neighbors = function(node) names(nodes[[node]]),
     cost_estimate = function(node, goal) 1,
     edge_distance = function(src, dst) nodes[[src]][dst],
     is_goal_reached = function(node, goal) identical(node, goal)
   )
 )

 searcher <- Searcher$new()
 path <- searcher$run('A', 'B')

machow/astar-r documentation built on May 12, 2019, 7:35 a.m.