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

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter 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]
43
Health:
Code health derived from static analysis. [more]
77
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
61
Learn more about scoring.

We analyzed this package on Oct 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in libraries.

Health suggestions

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

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

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

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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

line 88 col 21: The value of the local variable 'dy' isn't used.

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

Additional issues in the following files:

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

Maintenance issues and suggestions

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