Modifying The Expansion Algorithm

Currently, the expansion algorithm checks for solution cycles through a call to OccursOnPath, which checks the path back from a newly created state to the root for a duplicate state (O(d[n])).

Checking for duplicate states on Closed performs the same function more efficiently (O(1)).

So we can eliminate the call to OccursOnPath from Expand:

Expand(u)
   children = {}
   for each move ∈ moves do
      child = move.doMove(u)
      if child ≠ null // and not OccursOnPath(child, u)
         then d[child] = d[u] + 1
              pred[child] = u
              add child to children
   return children

Note that some (and perhaps many) of the states returned by Expand will simply be discarded by the enhanced Search.