Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I haven't looked closely at the algorithm/logic, but here is how I would touch it up:</p> <pre><code>let rec pathFind (area:map,start, goal, openNodes:PathingNode list, closedNodes:PathingNode list)= let rec checkNeighbours (opn, neighbours) = match neighbours with | [] -&gt; opn | hd::tl -&gt; if List.exists (fun x -&gt; x.point = hd.point &amp;&amp; x.f &gt; hd.f) opn then checkNeighbours(remove opn (fun x -&gt; x.point = hd.point), tl) elif not(List.exists (fun x -&gt; x.point = hd.point) closedNodes) &amp;&amp; not(List.exists (fun x -&gt; x.point = hd.point) opn) then checkNeighbours({hd with parent = Some(openNodes.Head)}::opn, tl) else checkNeighbours(opn, tl) let neighbours = area.GetNeighboursOf(openNodes.Head.point) |&gt; List.map (fun mp -&gt; nodeToPathNode(mp, openNodes.Head, goal)) |&gt; List.filter (fun pnd -&gt;pnd.point.value = 0) let openLocalNodes = checkNeighbours(openNodes.Tail, neighbours) if List.exists (fun x -&gt; x.point = goal) openLocalNodes then {point=goal; h=0; g=goal.Distance(start); parent=Some(openNodes.Head)} else pathFind(area, start, goal, openLocalNodes, openNodes.Head::closedNodes) </code></pre> <p><code>PathingNode</code> - types begin with capital letters (<code>list</code>/<code>option</code>/<code>array</code>/<code>ref</code> are the only exceptions).</p> <p>Whitespace after every comma, semicolon, or vertical bar.</p> <p>Lessen indent after <code>hd::tl</code> line, and use <code>elif</code> rather than <code>else if</code>.</p> <p>Get rid of lots of unneeded parentheses (<code>f x</code> not <code>f(x)</code>, <code>if cond then</code> not <code>if(cond) then</code>).</p> <p>Pipelining style a little more (<code>let neighbours=...</code>).</p> <p>Otherwise, at a glance this looks good.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload