I want to ask an assignment question. I know some people hesitate to give answers to this kind of question, but believe me, I have spent a lot of time on this assignment and have tried everything I could. So please help if you could.
The question is a rogue-like AI game in a grid format, one of the test cases is a map like the following:
g=gold, d=dynamite, ~=water, *=wall, < is our agent, facing left.
The rules are that the agent cannot move into the water nor the wall. It can only move to an empty square or to a d square to pick up dynamite. It can then blast a wall with the dynamite. Once the dynamite is used, it can't be used again. The ultimate goal is to find the gold and pick it up. The agent can only move up and down or left and right. No diagonal moves.
Due to the text formatting, there may appear some extra spaces between the walls in the diagonal direction, but there aren't any.
So far I've used Depth First Search to explore the map. (This example map is quite small, there are some that are big). I've also used A* search to plan for paths, with Manhattan distance as the heuristics.
What's tricky about this map is that, A* search can't find a path to the goal, and the only solution is to first pick up the dynamite near the agent and then blast the second wall to the right of the gold, then go right to pick up the second dynamite, and then go back to blast the last wall to the right of the gold, and then get the gold.
I'm stuck with the following issues:
A* search only gives me a path to the goal if it finds one. It doesn't give an "almost-there" path.
I can use A* to search for the path either for the gold or the dynamite, but not both at the same time. It seems that, in this case, I need to search the best path for getting the dynamite first and then the gold, in one routine. That sounds too hard...Please tell me if that is the wrong direction.
If anyone has any suggestions or good advice, please enlighten me. I haven't slept for two days...
Thanks for reading.
[EDITED 30/05] Well, I managed to use a trick to solve the above map. Basically, search backward from the gold, and assume if the first level neighboring walls are clear and see if the agent can move there and also can pick up any dynamite from there. if both, then it's a through the path.
But, looking at the following maps, I'm speechless.....can anyone help?
Can anyone shed some light? appreciated...