Skip to content

Simple algorithms in javascript for solving mazes

Notifications You must be signed in to change notification settings

nemo-js/maze-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Maze.js

Various algorithms for path traversal implemented in javascript

  • DFS
  • BFS

Example

    // the map is represented by a two dimentinal array
    var map = 
        [
            [0, 0, 1, 0, 0, 0],
            [0, 0, 0, 0, 0, 1],
            [0, 1, 0, 0, 0, 1],
            [0, 1, 1, 0, 0, 0],
            [0, 0, 1, 1, 0, 1]
        ];
        
    var start = { x: 4, y: 0 };
    var end = { x: 1, y: 4 };

    // for DFS
    var dfsNodes = SearchAlgorithms.dfs(map, start, end);
    // for BFS
    var bfsNdes = SearchAlgorithms.dfs(map, start, end);

    // all algorithms return an array with all visited nodes
    // the nodes which exist in the path have the 'inPath' property true

About

Simple algorithms in javascript for solving mazes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published