Giter Club home page Giter Club logo

pathfindingforobjc's Introduction

PathFindingForObjC

A Comprehensive PathFinding Library for Objective-C.
Based on PathFinding.js by @qiao.

Installation

Cocoapods

  • Edit your Podfile
pod 'PathFindingForObjC'

or use the master branch of the repo :

pod 'PathFindingForObjC', :git => 'https://github.com/wbcyclist/PathFindingForObjC.git'
  • Add #import <PathFindingForObjC/PathFinding.h> to your source file.

Disable logging

add this code in Podfile

post_install do |installer|
	installer.project.targets.each do |target|
		target.build_configurations.each do |config|
			if target.name.include? 'PathFindingForObjC'
				preprocessorMacros = config.build_settings['GCC_PREPROCESSOR_DEFINITIONS']
				if preprocessorMacros.nil?
					preprocessorMacros = ['$(inherited)', 'COCOAPODS=1'];
				end
				preprocessorMacros << 'PF_DEBUG=0'
				config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = preprocessorMacros
			end
		end
	end
end

Manually

  1. Download the latest code version or add the repository as a git submodule to your git-tracked project.
  2. Open your project in Xcode, then drag and drop PathFindingForObjC/PathFindingForObjC into your project
  3. Add #import PathFinding.h to your source file.

Disable logging

Click on your Project Target, head over to Build Settings and search for Preprocessor Macros. add PF_DEBUG=0 to Debug Configuration.

Basic Usage

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];
debug log:

๐Ÿ” ๐Ÿ” ๐Ÿ” ๐Ÿ” ๐Ÿ” ๐Ÿ”

๐Ÿ” ๐Ÿ” ๐Ÿ™ ๐Ÿ’— ๐Ÿ’— ๐Ÿ”

๐Ÿ” ๐Ÿ”ž ๐Ÿ”ž ๐Ÿ”ž ๐Ÿ’— ๐Ÿ”

๐Ÿ” ๐Ÿ” ๐Ÿ™… ๐Ÿ’— ๐Ÿ’— ๐Ÿ”

๐Ÿ” ๐Ÿ” ๐Ÿ” ๐Ÿ” ๐Ÿ” ๐Ÿ”

Options

HeuristicType :

  • HeuristicTypeManhattan
  • HeuristicTypeEuclidean
  • HeuristicTypeOctile
  • HeuristicTypeChebyshev

DiagonalMovement :

  • DiagonalMovement_Always
  • DiagonalMovement_Never
  • DiagonalMovement_IfAtMostOneObstacle
  • DiagonalMovement_OnlyWhenNoObstacles

PathfindingAlgorithm :

  • PathfindingAlgorithm_AStar
  • PathfindingAlgorithm_BestFirstSearch
  • PathfindingAlgorithm_Dijkstra
  • PathfindingAlgorithm_JumpPointSearch
  • PathfindingAlgorithm_BreadthFirstSearch
  • PathfindingAlgorithm_BiAStar
  • PathfindingAlgorithm_BiBestFirst
  • PathfindingAlgorithm_BiDijkstra
  • PathfindingAlgorithm_BiBreadthFirst

##DEMO

OS X

  • iOS

iOS

License

  • MIT

pathfindingforobjc's People

Contributors

wbcyclist avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.