movement equivalence classes
These can be used as a basis for a bunch of pathing optimizations. - Feasability of movement can be precomputed for each class, avoiding the worst-case pathfinding behavior - A path could potentially be shared between all members of a class. This isnt necessarily the best path for any single unit, as it doesn't care about efficiency of movement across various terrain -- but it would be a "reasonable" path that the whole group could take together. - General pathing checks can be converted from intersection of sets of strings to a simple AND. - Other, wilder things. V2: be paranoid about too-long bit vectors.
This commit is contained in:
@@ -225,6 +225,20 @@ namespace OpenRA
|
||||
}
|
||||
|
||||
public static Rectangle Bounds(this Bitmap b) { return new Rectangle(0, 0, b.Width, b.Height); }
|
||||
|
||||
public static int ToBits(this IEnumerable<bool> bits)
|
||||
{
|
||||
var i = 0;
|
||||
var result = 0;
|
||||
foreach (var b in bits)
|
||||
if (b)
|
||||
result |= (1 << i++);
|
||||
else
|
||||
i++;
|
||||
if (i > 33)
|
||||
throw new InvalidOperationException("ToBits only accepts up to 32 values.");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Enum<T>
|
||||
|
||||
Reference in New Issue
Block a user