Hey guys,
I am doing a game like Perilous Path, here’s a link showing the game - YouTube.
So what I did was I am generating a 6x6 grid of buttons.I am assigning randomly 10 buttons with “mines” and assigning randomly 2 buttons with stars representing the buttons that have to be connected.I want to implement a scoring system, i want to use some sort of algorithm that will calculate the shortest path between the “star” buttons, then compare that shortest path with the path the user made by playing the game.Can anyone point me in the right direction, I’ve read a bit about A* but is that the right approach to find the shortest path between two buttons?Btw the algorithm should take the mines into consideration too, so when it calculates the path it should avoid the buttons assigned with mines. Any help would be appreciated.
Thanks in advance
If you want to get into it, there are tons of things you can do to make this algorithm better for your specific needs.
Let’s say this is your field:

If you want to be really clever, you can first let the algorithm downsize your window like this:

And check if a route is possible. If it’s not, you add more area within the direction an opening could be created (in the case, the blockade is on a vertical line between the 2 points, so the area should expand horizontally.) Then that can snowball into all other kinds of implementations.
However, I am NOT going to think too much on this solution, simply because it seems redundant to work it out. You sport a really lightweight game, and 1000nds of calculations per second is just what computers are good at, so you might as well just use A*.
If you need help with implementation, here you go! Just switch Location with Vector2 and you’re all set! There might be a view differences between the example to account for, but I’m sure you can figure them out; the basic principle is there.
Good luck!