So, this
article on memristors and maze solving came across my feeds a few days ago. The paper it reports on is a surprisingly easy read (and the pictures at the end are enlightening), so consider reading it.
Basically, some guys built an array of
memristors, overlaid a maze (the walls broke connections between the adjacent memristors), chose start and end points and ran a current through them.
Memristors hold a memory of the current that flows over them. Current in one direction increases the resistance, current in the other direction reduces it. If you start from a clear array (minimum resistance) then the path will be marked by a series of memristors with high resistance compared to no change for the memristors not on the path.
In scenarios in which a maze has multiple solutions, the array finds
all viable paths with the shortest marked with the highest resistance, the longest with the lowest resistance (but not 0, which is no path), and other paths in between depending on length.
This process can be modeled in software, and as each memristor performs a single, identical operation, this can be easily parallelized.
You can probably imagine how this might be useful in DF:
- Each pathable tile in the DF map is a node on the memristor array. Filled tiles (walls, buildings, locked doors, etc.) do not have a node, and no connections are made through it.
- An operation that creates an pathable tile adds a new node (mining, unlocking a door, draining an pond, building stairs, lowering/extending a bridge, etc., etc.), with the appropriate neighbor connections
- The reverse removes a node (building a wall, locking a door, raising a bridge, etc., etc.).
The maze constructed in the paper is a straight grid, but DF connects tiles that share a corner, so rather than the four memristors per node in the paper, in DF this would need to be eight.
From there, when a units wants a path, it uses its current position as the start point, and the desired location as end, and the memristor algorithm does it's thing and now you have every path to the destination, sortable by length. To fully take advantage of this, such an algorithm should be multi-threaded (not just it's own thread, but possibly multi-threaded
itself), but this is a long-desired enhancement to DF in general.
The current system's traffic designation system can still be implemented: once you have a list of paths (which are themselves lists of tiles), the traffic designations on those tiles can be taken into account (so, sort by length, then by cost; or cost, then length, whichever produces better results).
As far as I can tell, it shouldn't be a problem to make this 3D: stairs and ramps would simply connect to the appropriate node in an adjacent level. This method should be highly expandable in terms of features: 4D connections should work the same way as stairs and ramps, so those "magic world" suggestions, gateways into them could be enabled by simply making another connection between a node in the 'real' world and the 'magic' world, and shortcuts in a single world would merely be an additional connection between the two end points of the shortcut, which may or may not have it's own memristor nodes in it (depending on how long it is to be).