Git Product home page Git Product logo

pathfinder's Introduction

Pathfinder

Description

This is simply an implementation I wrote in Swift 3.1 for a school project of the three pathfinding algorithms: A*, Breadth First Search, and Dijkstra's. The difference between the three is in how they sort the list of "open" nodes, and can be seen in the func insertIntoOpen(node: Node) function in Pathfinder.swift.

The app should work on both iPhone, iPod Touch, and iPad, but in all cases will work best in landscape mode (set in settings by default).

The app works by loading in two types of text files: some with simply a maze (with the prefix board-1-...), and some with landscape where different tiles have different costs. The costs are shown below.

Costs For the Landscape Maps

  • Water: 100
  • Mountains: 50
  • Forests: 10
  • Grasslands: 5
  • Roads: 1
  • Start and End: 1

As for the mazes (boards 1-x.txt), the obstacles are specially taken care of to be inpenetrable. See the func getSuccessorNodes(node: Node) -> [Node] function in Pathfinder.swift.

Demo

What the path is should be pretty obvious from these screenshots. The circles are the nodes in the open list, and the crosses are the nodes in the closed list. Learn more about those here: A* Algorithm on Wikipedia

Board 1-3 using A* Board 1-3 using A*

Board 1-3 using BFS Board 1-3 using BFS

Board 2-4 using A* Board 2-4 using A*

Board 2-4 using BFS Board 2-4 using BFS

pathfinder's People

Contributors

jasonmccoy avatar vegather avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.