pathfinding 2.0.0

PathFinding.dart #

A Dart port of https://github.com/qiao/PathFinding.js library

Installing #

http://pub.dartlang.org/packages/pathfinding#installing

Usage: #

import 'package:pathfinding/finders/jps.dart';
import 'package:pathfinding/core/grid.dart';

main() {
  var grid = new Grid(4, 4, [
    [0, 0, 1, 1], // 0 - walkable, 1 - not walkable
    [1, 0, 1, 1],
    [1, 0, 1, 1],
    [1, 0, 0, 0]
  ]);
  var jps = new JumpPointFinder();
  var path = jps.findPath(0, 0, 3, 3, grid);
  print(path); // [[0, 0], [1, 1], [1, 2], [2, 3], [3, 3]]
}

Available finders: #

  • AStar
  • JumpPointFinder

TODO:

  • BreadthFirst
  • Dijkstra
  • BiBreadthFirst
  • BiDijkstra
  • BiAStarFinder
  • BestFirstFinder
  • BiBestFirstFinder

Benchmarks #

Dart SDK version 0.5.16.0_r23799

Dartium

AStarFinder(RunTime): 146642.85714285713 us.
JumpPointFinder(RunTime): 38301.88679245283 us. 

dart2js

AStarFinder(RunTime): 265750 us. 
JumpPointFinder(RunTime): 105631.57894736843 us.

example/example.dart

import 'package:pathfinding/finders/jps.dart';
import 'package:pathfinding/finders/astar.dart';
import 'package:pathfinding/core/grid.dart';

main() {
  var grid = new Grid(4, 4, [
    [0, 0, 1, 1], // 0 - walkable, 1 - not walkable
    [1, 0, 1, 1],
    [1, 0, 1, 1],
    [1, 0, 0, 0]
  ]);
  var path = new JumpPointFinder().findPath(0, 0, 3, 3, grid.clone());
  print(path); // [[0, 0], [1, 1], [1, 2], [2, 3], [3, 3]]

  path = new AStarFinder().findPath(0, 0, 3, 3, grid.clone());
  print(path); // [[0, 0], [1, 0], [1, 1], [1, 2], [1, 3], [2, 3], [3, 3]]
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  pathfinding: ^2.0.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:pathfinding/core/grid.dart';
import 'package:pathfinding/core/heap.dart';
import 'package:pathfinding/core/heuristic.dart';
import 'package:pathfinding/core/node.dart';
import 'package:pathfinding/core/util.dart';
import 'package:pathfinding/finders/astar.dart';
import 'package:pathfinding/finders/jps.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
52
Health:
Code health derived from static analysis. [more]
75
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
60
Overall:
Weighted score of the above. [more]
60
Learn more about scoring.

We analyzed this package on Jan 19, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health suggestions

Fix lib/core/heap.dart. (-9.54 points)

Analysis of lib/core/heap.dart reported 20 hints, including:

line 17 col 1: Prefer using /// for doc comments.

line 32 col 11: Unnecessary new keyword.

line 48 col 1: Prefer using /// for doc comments.

line 59 col 1: Prefer using /// for doc comments.

line 78 col 1: Prefer using /// for doc comments.

Fix lib/core/grid.dart. (-8.17 points)

Analysis of lib/core/grid.dart reported 17 hints, including:

line 5 col 1: Prefer using /// for doc comments.

line 36 col 3: Prefer using /// for doc comments.

line 47 col 13: Unnecessary new keyword.

line 48 col 5: The value of the local variable 'row' isn't used.

line 51 col 18: Unnecessary new keyword.

Fix lib/finders/jps.dart. (-4.89 points)

Analysis of lib/finders/jps.dart reported 10 hints, including:

line 16 col 1: Prefer using /// for doc comments.

line 35 col 3: Prefer using /// for doc comments.

line 41 col 36: Unnecessary new keyword.

line 73 col 3: Prefer using /// for doc comments.

line 88 col 17: The value of the local variable 'dx' isn't used.

Fix additional 4 files with analysis or formatting issues. (-9.89 points)

Additional issues in the following files:

  • lib/finders/astar.dart (7 hints)
  • lib/core/util.dart (6 hints)
  • lib/core/node.dart (4 hints)
  • lib/core/heuristic.dart (3 hints)

Maintenance issues and suggestions

No valid SDK. (-20 points)

The analysis could not detect a valid SDK that can use this package.

Provide a file named CHANGELOG.md. (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
benchmark_harness any
test any