Search Unity

How to find shortest path between buttons?

Discussion in '2D' started by cupcakehox, Jul 5, 2018.

  1. cupcakehox

    cupcakehox

    Joined:
    May 11, 2018
    Posts:
    3
    Hey guys,

    I am doing a game like Perilous Path, here's a link showing the game
    . 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
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Yes, this sort of problem is exactly what A* is for.