A* Admissible Heuristic for die rolling on grid

前端 未结 5 1451
盖世英雄少女心
盖世英雄少女心 2020-12-23 14:21

I need some help finding a good heuristic for the following problem:

You are given an R-by-C

5条回答
  •  暖寄归人
    2020-12-23 14:32

    Idea:

    If you have to move in a straight line, the best you can do is to end your moves with 1 and 2, for all other moves you can't do better than 3.5*distance.

    Heuristic:

    With ManhattanDistance = x + y the following heuristic could be used:

    Heuristic = xH + yH;
    

    where

    xH = calculateStraightLineHeuristic(x)
    yH = calculateStraightLineHeuristic(y)
    

    and the function calculateStraightLineHeuristic(z) is defined as follows:

    calculateStraightLineHeuristic(z)
        if (z = 1)
            return zH = 1
        elseif (z = 2)
            return zH = 2+1
        else
            return zH = (z-2)*3.5+2+1
    end
    

提交回复
热议问题