Pathfinding using room "Difficulty"?

Hi guys,

i am trying to work on a random dungeon generator.
The idea is to have a grid, place a start and exit point, fill the grid with randomly sized rectangles (which represent other rooms) and assign a difficulty level to each room (depending on some factors like size).

The result is something like this:

Now i need to find a way from Start To End, but i want to consider the room difficulty (green = easy, red = difficult).
Once i get the path, i would use every room that the path touched and remove all the other rooms, to get my dungeon.

The question i have though is, how do i generate a path that goes from A to B but avoids anything difficult if it can, and only walk through rooms that are harder if it can’t find a different way?

Would i be able to use A* for this and “somehow” weight each tile on the grid depending on what the room difficulty is? Or are there any “easier/simpler” solutions to this?

Thanks!

Alright i figured it out, and all i really needed was an A* Pathfinding system and add the difficulty for each room to the cost of each node.

The result looks like this :smile: