I hope this is the correct subpage of SE, if not please direct me to the more appropriate place.
Imagine the following scenario:
You are put into a random but known position inside a given maze. The maze contains, in addition to walls (█) and pathways (.), the following things:
- R - A refresh point which is single use but when used refreshes the amount of steps you can take.
- S - A save point which is multi use and gives you a known position you can start from (instead of a random position) but does not refresh your steps while inside the maze. If used to re-enter it grants you a full set of steps. Only relevant if algorithm can account for multiple re-entries (see optional optimizations below).
- T - A treasure chest, which gives you some form of reward (the reward itself is irrelevant for the pathing algorithm)
- M - A monster which you will need to fight if you encounter it. It will drop some treasure if defeated, but any damage it does to you will need to be regenerated (so a time penalty) or, if it defeats you, you get kicked out of the maze and need to re-enter it (either randomly or through a previously passed save point).
Used / looted / defeated status of a tile preserve between runs.
You have a maximum of 30 steps you can take before you get kicked out of the maze from exhaustion, unless refreshed at a refresh point.
Mazes are always square, with a side length of 160 tiles.
Example part of a maze:
█ █ █ . █ █ █ █ █
. . . . █ . . M █
█ █ █ █ █ . █ . █
M . █ . . R █ . █
█ R █ . █ █ █ . █
█ M . . █ . █ . █
█ █ █ M █ S █ . █
█ . █ . T . . . █
█ . █ . █ █ █ R █
What is a good way, given the mentioned restrictions, to find the path, starting from your current position, that passes by the most treasures (and monsters) before you're kicked out of the maze of exhaustion?
What I tried
I tried creating a graph of nodes based on the refresh points as the nodes and the paths between them as the connections, giving a higher value to more points of interest between nodes. I then used a modified Dijkstra algorithm to find the path with the highest value.
Unfortunately, while it works somewhat, it doesn't take into account what treasures/monsters have already been visited, often leading to high density areas of the map being covered many times over, requiring human intervention for improvement of said path (which more often than not has caused user error and a miscount, leading to a failed run).
I'm thankful for any ideas and suggestions as to how to tackle this.
Optional optimizations / extensions:
- allow backtracking where it makes sense
- use save points strategically to come back to and cover more area, spanning multiple runs.
- allow the use of different weights to prioritize/avoid treasures/monsters by user preference
- there is a single boss inside this maze, which is the ultimate "goal" of it. Make the path end there, while still picking up as many treasures on the way as possible.
- whatever else you can think of