48 int cycles,
float* potential) {
50 int start_i =
toIndex(start_x, start_y);
54 potential[start_i] = 0;
56 int goal_i =
toIndex(end_x, end_y);
59 while (
queue_.size() > 0 && cycle < cycles) {
68 add(costs, potential, potential[i], i + 1, end_x, end_y);
69 add(costs, potential, potential[i], i - 1, end_x, end_y);
70 add(costs, potential, potential[i], i +
nx_, end_x, end_y);
71 add(costs, potential, potential[i], i -
nx_, end_x, end_y);
79 void AStarExpansion::add(
unsigned char* costs,
float* potential,
float prev_potential,
int next_i,
int end_x,
81 if (next_i < 0 || next_i >=
ns_)
91 int x = next_i %
nx_,
y = next_i /
nx_;
92 float distance = abs(end_x - x) + abs(end_y - y);
AStarExpansion(PotentialCalculator *p_calc, int nx, int ny)
virtual float calculatePotential(float *potential, unsigned char cost, int n, float prev_potential=-1)
std::vector< Index > queue_
TFSIMD_FORCE_INLINE const tfScalar & y() const
unsigned char lethal_cost_
int toIndex(int x, int y)
unsigned char neutral_cost_
double distance(double x0, double y0, double x1, double y1)
TFSIMD_FORCE_INLINE const tfScalar & x() const
PotentialCalculator * p_calc_
static const unsigned char NO_INFORMATION
void add(unsigned char *costs, float *potential, float prev_potential, int next_i, int end_x, int end_y)
bool calculatePotentials(unsigned char *costs, double start_x, double start_y, double end_x, double end_y, int cycles, float *potential)