Latest 1.0.0
Homepage https://github.com/d-32/HeatMapPath
License MIT
Platforms ios 7.0, requires ARC
Authors

Build Status
Version
License
twitter: @dylan36032

Goal-Based vector field path finding for iOS.

If you need to calculate the shortest path for many objects with the same target then this approach should be more efficient than traditional path finding algorithms. It creates a heatmap for the whole map, which takes time. But for each object it than only has to follow the heatmap values.

image

Installation

HeatMapPath is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "HeatMapPath"

If you’re not using CocoaPods you’ll find the source code files inside Pod/Classes.

Usage

Tile

Just create your own Tile class which implements the protocol DMTile.

Add the two synthesize:

@synthesize distance;
@synthesize position;

And add the method costFromSource:

- (int)costFromSource:(id<DMTile>)sourceTile {
    return 1;
}

Here you can return the cost for that tile. How you’ll do that is your choice. You get the source tile (the one that’s before it in the path) if your cost is different depending on the direction.

HeatMap

Initialize a DMHeatMap and keep it as member. Set the map property. The map property should be an array of arrays. The outer array is for each row. And each row is an NSArray with your tiles for that row. Hope this doesn’t sound too complicated.

Everytime your target changes you’ll have to set the target property and call the method generate.

For each object that needs a new path just call the method points:.

Demo

http://www.youtube.com/watch?v=Y3H0WLZHtzU

Diagonal

At the moment it doesn’t support diagonal moves, as for my use case this wasn’t needed. You can add this functionality quite easily. Just look at where neighbors are determined. Should be done at two places, once for the heatmap and once for the path finding.

Latest podspec

{
    "name": "HeatMapPath",
    "version": "1.0.0",
    "summary": "Goal-Based vector field path finding.",
    "homepage": "https://github.com/d-32/HeatMapPath",
    "license": "MIT",
    "authors": {
        "Dylan Marriott": "[email protected]"
    },
    "source": {
        "git": "https://github.com/d-32/HeatMapPath.git",
        "tag": "1.0.0"
    },
    "social_media_url": "https://twitter.com/dylan36032",
    "screenshots": "http://46.105.26.1/uploads/heatmap.png",
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes",
    "resource_bundles": {
        "HeatMapPath": [
            "Pod/Assets/*.png"
        ]
    }
}

Pin It on Pinterest

Share This