private bool Check(Vec cell, List <Vec> bots) { filled[cell] = true; int comps = 0; var toCheck = cell.GetMNeighbours(toFill).Where(c => !filled[c]).ToList(); var botLocations = new HashSet <Vec>(bots); timer++; foreach (var v in toCheck) { if (used[v] == timer) { continue; } var(cells, finished) = BfsSmall(v); comps++; if (!finished) //TODO { continue; } if (cells.Any(c => c == Vec.Zero)) { continue; } if (cells.Any(c => !filled[v] && toFill[v] || botLocations.Contains(v))) { return(false); } } if (comps == 1) { return(true); } Bfs(Vec.Zero); var result = true; for (int x = 0; x < n; x++) { for (int y = 0; y < n; y++) { for (int z = 0; z < n; z++) { var v = new Vec(x, y, z); if (used[v] == timer) { continue; } if (!filled[v] && toFill[v] || botLocations.Contains(v)) { result = false; } } } } return(result); }
public PathFinder(DeluxeState state, Bot bot, Vec target) : this(state.Matrix.Voxels, bot.Position, target, vec => !state.IsVolatile(bot, vec)) { }
public PathFinder(bool[,,] state, Vec source, Vec target, HashSet <Vec> volatiles, Region region) : this(state, source, target, vec => (volatiles == null || !volatiles.Contains(vec)) && (region == null || vec.IsInRegion(region))) { }
private bool CanFill(Vec cell, int from) { var closed2 = Closed[cell] | (1 << from); return(closed2 != 0b11111); }