TilemapKit is now able to generate grid graphs from tile costs. Rather than using walkable/blocked flags on tiles you would use a “cost” property whose floating point value is in the range 0.0 to infinity.
Though you should try to restrict your value range from 0.0 to 1.0 or 0 to 100, that’ll make it easier to get a feel for the relation of individual cost values.
In this example, the road has a cost of 0.5 while grass is 3.0, ice is 4.0 and mud is 6.0. Any tile without a cost is considered blocked, but you can also specify a negative value to block off a tile.
The code to generate this graph is even simpler than what you would use for non-cost based graphs:
NSDictionary* costs = [map tileValuesForPropertyNamed:@"cost"];
GKGridGraph* graph = [map gridGraphForTileLayersNamed:@[@"Ground", @"Objects"]
Each node in the cost graph uses the TKGridGraphNode subclass of GKGridGraphNode, which adds a cost property and implements the costToNode: function to simply return the cost.
You can further subclass this class and override the costToNode: function if you need to base the cost on certain conditions. Or you could fix certain undesirable behavior such as where the roads don’t actually connect even though their tiles are neighbors the cost should probably be higher. You can see this issue in the video if you watch closely: