Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global open_list = [];
- global closed_list = [];
- function dijkstra(cell1, cell2)
- {
- push(open_list, getCell());
- while (count(open_list) > 0)
- {
- var current = shift(open_list);
- if (!inArray(closed_list, current))
- {
- push(closed_list, current);
- pushAll(open_list, getNearestCells(current));
- }
- }
- }
- function getNearestCells(cell)
- {
- var x = getCellX(cell);
- var y = getCellY(cell);
- return [getCellFromXY(x + 1, y + 1),
- getCellFromXY(x + 1, y - 1),
- getCellFromXY(x - 1, y + 1),
- getCellFromXY(x - 1, y - 1)];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement