From ScummVM :: Wiki
< SCI‎ | FreeSCI‎ | Pathfinding
Jump to navigation Jump to search

Conclusions and recommendations for future work

The main goal of this internship was to implement the voidPath function without infringing Sierra’s pathfinding patent. We accomplished this by choosing an algorithm that is very different from the one described in the patent. The algorithm we chose has one advantage over the algorithm used by Sierra, namely that it always computes the shortest path. Our implementation performed well in the basic tests we performed. However, at this time we are aware of two limitations.

The first limitation is related to the rounding of intersecting points as in Rounding real numbers section. Our implementation tries nearby points in ℤ2. If an intersected polygon is very thin, a rounded point may end up on the wrong side of the polygon. This would make it possible to walk through very thin polygons with the keyboard. We used the experimentator to test very thin polygons in Sierra SCI and we observed that it suffers from the same limitation. A possible solution for this problem would be to ignore rounded points that lie left of the intersected edge.

The second limitation is related to Assumption 2. In practice there are game scenes that contain intersecting polygons, and thus violate this assumption. As we currently know of only one scene for which this is the case (Conquests of the Longbow, room 210.), this issue was ignored for the present project. This scene works correctly in Sierra SCI, even though tests with the experimentator showed that Sierra SCI does not support intersecting polygons in general. If there are more game scenes that violate the assumption, it might be necessary to add support for intersecting polygons.

This would create an interesting problem as the visibility graph algorithm we used is fundamentally incompatible with intersecting polygons.

The algorithm stores the edges that the sweeping line intersects in a tree, ordered by distance. Let e0 and e1 be edges. If e0 and e1 do not intersect then their ordering does not depend on the position of the sweeping line, but if they intersect at a point p this ordering flips when the sweeping line hits p. It may be possible to store intersection points and initiate a tree reordering when the sweeping line hits an intersection point. However, it might be better to detect intersecting polygons and fall back to the trivial O(n3) algorithm, which does not make use of such an ordered data structure. Other problems arise when a vertex v of one polygon lies on an edge e of another. In that case it would be possible to create a path that goes through e via v, as e does not properly intersect any edges incident to v and thus would not obstruct visibility.

It may be possible to add support for intersecting polygons by first merging the intersecting polygons into one polygon. In some cases this does not work, however. Let P and Q be two polygons whose intersection is a single point p. If we now merge P and Q we get a polygon that is self-intersecting at p, which would still be illegal input for the visibility graph algorithm as it violates Assumption 1.

All of this suggests that there is no quick fix that adds support for intersecting polygons. If it turns out that support for intersecting polygons is necessary, further research will need to be performed.