public static bool DynamicCheck(StaticMaps staticMaps, IStateMaps node) { var constraintsMap = new BitmapSpan(staticMaps.WallMap.Size, stackalloc uint[staticMaps.WallMap.Height]); constraintsMap.SetBitwiseOR(staticMaps.WallMap, node.CrateMap); return(DynamicCheck(staticMaps, node, constraintsMap)); }
public static bool DynamicCheck(StaticMaps staticMaps, IStateMaps node, BitmapSpan both) { // Box Rule foreach (var crate in node.CrateMap.TruePositions()) { if (staticMaps.GoalMap[crate]) { continue; } if (both[crate + VectorInt2.Left] && both[crate + VectorInt2.Left + VectorInt2.Down] && both[crate + VectorInt2.Down] ) { return(true); } if (both[crate + VectorInt2.Left] && both[crate + VectorInt2.Left + VectorInt2.Up] && both[crate + VectorInt2.Up] ) { return(true); } if (both[crate + VectorInt2.Right] && both[crate + VectorInt2.Right + VectorInt2.Down] && both[crate + VectorInt2.Down] ) { return(true); } if (both[crate + VectorInt2.Right] && both[crate + VectorInt2.Right + VectorInt2.Up] && both[crate + VectorInt2.Up] ) { return(true); } } return(false); }
public static bool DynamicCheck(StaticMaps staticMaps, IStateMaps node) { var both = staticMaps.WallMap.BitwiseOR(node.CrateMap); // Box Rule foreach (var crate in node.CrateMap.TruePositions()) { if (staticMaps.GoalMap[crate]) continue; if (both[crate + VectorInt2.Left] && both[crate + VectorInt2.Left + VectorInt2.Down] && both[crate + VectorInt2.Down] ) { return true; } if (both[crate + VectorInt2.Left] && both[crate + VectorInt2.Left + VectorInt2.Up] && both[crate + VectorInt2.Up] ) { return true; } if (both[crate + VectorInt2.Right] && both[crate + VectorInt2.Right + VectorInt2.Down] && both[crate + VectorInt2.Down] ) { return true; } if (both[crate + VectorInt2.Right] && both[crate + VectorInt2.Right + VectorInt2.Up] && both[crate + VectorInt2.Up] ) { return true; } } return false; }
public static Result Find(StaticMaps staticMaps, IStateMaps state, VectorInt2 crate, VectorInt2 player) { var start = new Node { PlayerAfter = player, CrateTarget = crate, Maps = state }; var evaluator = new Evaluator(new Bitmap(state.CrateMap.Size), staticMaps); var itt = new BreadthFirstItterator <Node>(); itt.Evaluate(start, evaluator, new ExitConditions { StopOnFirstSolution = true } ); return(new Result { CrateMap = evaluator.CrateMap, Root = start }); }