darozak / Advolition

1 stars 0 forks source link

Create a routine that will allow the robot to take the shortest path to a destination #73

Closed darozak closed 3 months ago

darozak commented 4 months ago

The robot must be able to return to places that it has visited before. However, it needs to take into account intervening walls.

I think the best way to solve this problem is by having the robot become the source for a gushing solution and the destination become a drain for that solution. The routine will iteratively allow the solution to spread throughout all known transversable dungeon tiles. The robot will then follow the the downward gradient in water level from its current location to it's destination, which will be the lowest point on the water level map.

darozak commented 3 months ago

This worked! I created a functional drift routine that allows the robot to "flood" all known dungeon tiles and follow the flow from the source (itself) to the sink (its destination) (https://github.com/darozak/Advolition/commit/9023a321faa76e2943bde65706350d074e1b38b4).

I think I can use this same routine to have the robot explore unknown spaces. All I need to do is make void tiles also serve as sinks in the explorer mode. This will essentially cause the water to flow off the edge of the map and the robot will drift through rooms and around corners to the nearest void space.

darozak commented 3 months ago

I think the best way to accomplish this is to create a function in the Drift class that will compile a list of all floor and door tiles that are adjacent to unscanned tiles. Then, after each flood cycle, the floodDungeon function will zero the water depth in all the tiles that are on this list, causing the water to flow toward these tiles.

darozak commented 3 months ago

Success! The robot now relies on the Drift class to both explore the dungeon and find its way to specific locations. I deleted the Splore class because I no longer need this. Drift works much better for this. (https://github.com/darozak/Advolition/commit/89a881dec91497bbbe229b1bd4772fffd22cb104)

Now I just need to take a little time to refactor and clean up the class.

darozak commented 3 months ago

Finished refactoring the Drift class (https://github.com/darozak/Advolition/commit/93e25648a9a99dcd570b840e4032940d6efe8a26). Everything works great!