Пример #1
0
        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));
        }
Пример #2
0
        public static IBitmap FindCorners(StaticMaps staticMaps)
        {
            var res = new Bitmap(staticMaps.FloorMap.Size);

            foreach (var floor in staticMaps.FloorMap.TruePositions())
            {
                // ##
                // #.
                if (staticMaps.WallMap[floor + VectorInt2.Up] &&
                    staticMaps.WallMap[floor + VectorInt2.Left]
                    )
                {
                    res[floor] = true;
                }

                // ##
                // .#
                if (staticMaps.WallMap[floor + VectorInt2.Up] &&
                    staticMaps.WallMap[floor + VectorInt2.Right]
                    )
                {
                    res[floor] = true;
                }

                // .#
                // ##
                if (staticMaps.WallMap[floor + VectorInt2.Down] &&
                    staticMaps.WallMap[floor + VectorInt2.Right]
                    )
                {
                    res[floor] = true;
                }

                // #.
                // ##
                if (staticMaps.WallMap[floor + VectorInt2.Down] &&
                    staticMaps.WallMap[floor + VectorInt2.Left]
                    )
                {
                    res[floor] = true;
                }
            }

            return(res);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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
            });
        }
Пример #5
0
 public PuzzleState(StaticMaps @static, StateMaps current)
 {
     Static  = @static;
     Current = current;
 }
Пример #6
0
 public Evaluator(IBitmap crateMap, StaticMaps @static)
 {
     CrateMap = crateMap;
     Static   = @static;
 }