Skip to content

Instantly share code, notes, and snippets.

@jdoig
Created July 29, 2011 10:10
Show Gist options
  • Save jdoig/1113562 to your computer and use it in GitHub Desktop.
Save jdoig/1113562 to your computer and use it in GitHub Desktop.
Main program file of first attempt at path finding in F#
open Tools
open Level
open Pathfinding
let level1 = {width=5;height=9;map=(loadMap @"C:\Test\lvl1.txt" |> Seq.toList)}
let start = level1.GetElement 4 8
let goal = level1.GetElement 4 0
let path = pathFind(level1,goal,start,[{point=start;h=start.Distance goal;g=0.0;parent=None}],[])
let rec readPath (path:PathingNode, list:PathingNode list) =
match path.parent.IsNone with
| true -> list
| false -> readPath (path.parent.Value, path.parent.Value::list)
let waypoints = readPath(path, [path])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment