Lame attempts to improve A*.
This commit is contained in:
committed by
Matthias Mailänder
parent
2abde381a7
commit
7e913c4bb7
@@ -171,7 +171,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
int newCost = cellInfo[p.Location.X, p.Location.Y].MinCost + cellCost;
|
||||
|
||||
// Cost is even higher; next direction:
|
||||
if (newCost >= cellInfo[newHere.X, newHere.Y].MinCost)
|
||||
if (newCost > cellInfo[newHere.X, newHere.Y].MinCost)
|
||||
continue;
|
||||
|
||||
cellInfo[newHere.X, newHere.Y].Path = p.Location;
|
||||
@@ -185,7 +185,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
}
|
||||
|
||||
// Sort to prefer the cheaper direction:
|
||||
Array.Sort(nextDirections, (a, b) => a.Second.CompareTo(b.Second));
|
||||
//Array.Sort(nextDirections, (a, b) => a.Second.CompareTo(b.Second));
|
||||
|
||||
return p.Location;
|
||||
}
|
||||
@@ -291,10 +291,11 @@ namespace OpenRA.Mods.RA.Move
|
||||
{
|
||||
return here =>
|
||||
{
|
||||
CVec d = (here - destination).Abs();
|
||||
int diag = Math.Min(d.X, d.Y);
|
||||
int straight = Math.Abs(d.X - d.Y);
|
||||
return (3400 * diag / 24) + (100 * straight);
|
||||
int diag = Math.Min(Math.Abs(here.X - destination.X), Math.Abs(here.Y - destination.Y));
|
||||
int straight = (Math.Abs(here.X - destination.X) + Math.Abs(here.Y - destination.Y));
|
||||
int h = (3400 * diag / 24) + 100 * (straight - (2 * diag));
|
||||
h = (int)(h * 1.001);
|
||||
return h;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA
|
||||
}
|
||||
|
||||
foreach (var p in cellWeights)
|
||||
layer[p.First.X, p.First.Y] = Math.Min(128, (layer[p.First.X, p.First.Y] / 2) + ((maxWeight - p.Second) * 64 / maxWeight));
|
||||
layer[p.First.X, p.First.Y] = Math.Min(128, (layer[p.First.X, p.First.Y]) + ((maxWeight - p.Second) * 64 / maxWeight));
|
||||
}
|
||||
|
||||
public void Render(WorldRenderer wr)
|
||||
@@ -61,6 +61,7 @@ namespace OpenRA.Mods.RA
|
||||
for (int i = world.Map.Bounds.Left; i <= world.Map.Bounds.Right; ++i)
|
||||
{
|
||||
var ploc = new CPos(i, j).ToPPos();
|
||||
if (layer[i, j] <= 0) continue;
|
||||
|
||||
var w = Math.Max(0, Math.Min(layer[i, j], 128));
|
||||
if (doDim)
|
||||
|
||||
Reference in New Issue
Block a user