寻路算法库:PathFindingForObjC

e2ex 10年前

PathFindingForObjC 是 objc 的寻路算法库,可用于 iOS 与 OSX。内附 iOS、OSX 演示例子。直接 git clone 或下载源码,pod install 后就可运行。

简单示例:

PathFinding *finder = [[PathFinding alloc] initWithMapSize:CGSizeMake(6, 5)                                                    tileSize:CGSizeMake(1, 1)                                                 coordsOrgin:CGPointZero];  finder.heuristicType = HeuristicTypeManhattan;  finder.movementType = DiagonalMovement_Never;    // add blocks  [finder addBlockTilePositions:@[PF_CGPointToNSValue(CGPointMake(1, 2)),                                  PF_CGPointToNSValue(CGPointMake(2, 2)),                                  PF_CGPointToNSValue(CGPointMake(3, 2))                                  ]];  // set start point  finder.startPoint = CGPointMake(2, 3);  // set end point  finder.endPoint = CGPointMake(2, 1);  // get result  NSArray *foundPaths = [finder findPathing:PathfindingAlgorithm_AStar IsConvertToOriginCoords:YES];

DEMO

项目主页:http://www.open-open.com/lib/view/home/1431590542107