public IEnumerable <AStarState> GetJumpsIntoFills(AStarState botState) { var currentWeight = botState.Weight; foreach (var adjacent in botState.EndPosition.GetAdjacents()) { if (!Matrix.Contains(adjacent) || Matrix.IsVoid(adjacent)) { continue; } var weight = currentWeight + GetInFillWeight(); if (!GroundedChecker.CanRemove(new[] { adjacent, botState.DestroyedCell }.Where(c => c != null).ToHashSet())) { continue; } yield return(new AStarState { Move1 = adjacent - botState.EndPosition, StartPosition = botState.EndPosition, EndPosition = adjacent, DestroyedCell = adjacent, LastDestroyedCell = botState.DestroyedCell, Weight = weight, Dad = botState, MaxPotentialWeight = weight + GetPotentialOptimalWeight(adjacent, botState.Straight), Straight = botState.Straight }); } }
private bool BreakesGrounding(State state) { if (state.Fill) { return(!curGroundChecker.CanPlace(state.Region.AllPoints().ToList())); } else { return(!curGroundChecker.CanRemove(state.Region.AllPoints().ToHashSet())); } }
public static void Test() { var modelFilePath = @"..\..\..\data\models\LA020_tgt.mdl"; var matrix = MatrixDeserializer.Deserialize(File.ReadAllBytes(modelFilePath)); var mongoOplogWriter = new JsonOpLogWriter(new MongoJsonWriter()); mongoOplogWriter.WriteLogName("GreedyGravityAI_IsGrounded"); var state = State.CreateInitial(matrix.R, mongoOplogWriter); mongoOplogWriter.WriteInitialState(state); var groundedChecker = new IsGroundedChecker(matrix); var vertexex = new List <Vector>(); for (int y = 0; y < matrix.R; y++) { for (int x = 0; x < matrix.R; x++) { for (int z = 0; z < matrix.R; z++) { var vector = new Vector(x, y, z); if (matrix.IsVoid(vector)) { continue; } vertexex.Add(vector); } } } var rand = new Random(); vertexex = vertexex.OrderBy(_ => rand.NextDouble()).ToList(); foreach (var vector in vertexex) { if (groundedChecker.CanRemove(vector)) { groundedChecker.UpdateWithClear(vector); continue; } mongoOplogWriter.WriteFill(vector); } mongoOplogWriter.Save(); }