Bomb dropping algorithm

后端 未结 30 831
挽巷
挽巷 2021-01-29 16:55

I have an n x m matrix consisting of non-negative integers. For example:

2 3 4 7 1
1 5 2 6 2
4 3 4 2 1
2 1 2 4 1
3 1 3 4 1
2 1 4 3 2
6 9 1 6 4
         


        
30条回答
  •  鱼传尺愫
    2021-01-29 17:54

    You could use state space planning. For example, using A* (or one of its variants) coupled with an heuristic f = g + h like this:

    • g: number of bombs dropped so far
    • h: sum over all values of the grid divided by 9 (which is the best result, meaning we have an admissible heuristics)

提交回复
热议问题