Unit pathfinding

This commit is contained in:
Anuken
2022-02-09 17:13:02 -05:00
parent a24a94d0b0
commit fa79c5e93a
23 changed files with 841 additions and 151 deletions

View File

@@ -96,17 +96,17 @@ public class BaseAI{
var field = pathfinder.getField(data.team, Pathfinder.costGround, Pathfinder.fieldCore);
if(field.weights != null){
int[][] weights = field.weights;
int[] weights = field.weights;
for(int i = 0; i < pathStep; i++){
int minCost = Integer.MAX_VALUE;
int cx = calcTile.x, cy = calcTile.y;
boolean foundAny = false;
for(Point2 p : Geometry.d4){
int nx = cx + p.x, ny = cy + p.y;
int nx = cx + p.x, ny = cy + p.y, packed = world.packArray(nx, ny);
Tile other = world.tile(nx, ny);
if(other != null && weights[nx][ny] < minCost && weights[nx][ny] != -1){
minCost = weights[nx][ny];
if(other != null && weights[packed] < minCost && weights[packed] != -1){
minCost = weights[packed];
calcTile = other;
foundAny = true;
}