openList.add(start);
while (openList.size() != 0) {
Pathable current = openList.getFirst();
int lowestscore = f_score.get(openList.getFirst());
for (Pathable node : openList) {
if (f_score.get(node) < lowestscore) {
current = node;
lowestscore = f_score.get(node);
}
}
if (current.equals(goal)) {
return reconstructPath(came_from, goal);
}
openList.remove(current);
closedList.add(current);
for (int i = -1; i <= 1; i++) {
for (int l = -1; l <= 1; l++) {
if (current.getPositionV2().x + i < nodes.length && current.getPositionV2().y + l < nodes[0].length && current.getPositionV2().x + i >= 0 && current.getPositionV2().y + l >= 0) {
if (current.isWalkable(current.equals(start))) {
if (Math.abs(i) != Math.abs(l) || allowVertical) {
Pathable neighbor = nodes[((int) current.getPositionV2().x + i)][((int) current.getPositionV2().y + l)];
// int additionalResistance = Main.world.getTile((int) neighbor.x,(int) neighbor.y).getAdditionWaycost();
int additionalResistance = neighbor.getWaycost();
int heuristic;
if (allowVertical) {
heuristic = (int) ( Math.abs(neighbor.getPositionV2().dst(goal.getPositionV2()) * standardWaycost));
} else {
heuristic = (int) (( Math.abs(neighbor.getPositionV2().x - goal.getPositionV2().x) + Math.abs(neighbor.getPositionV2().y - goal.getPositionV2().y)) * standardWaycost);
}
int tentative_g_score = g_score.get(current) + additionalResistance;