Esempio n. 1
0
 /// <summary>
 /// Strong Construction
 /// </summary>
 /// <param name="controller">Controller/Owner</param>
 public RoomAnalysis(SolverController controller)
 {
     this.controller = controller;
     doors = new List<Door>();
     rooms = new List<Room>();
     doorBitmap = new SolverBitmap("Doors", controller.Map.Size);
 }
Esempio n. 2
0
        /// <summary>
        /// Find all puzzle corner cells
        /// </summary>
        /// <param name="staticAnalysis"></param>
        /// <returns></returns>
        public SolverBitmap FindCorners(StaticAnalysis staticAnalysis)
        {
            SolverBitmap cornerMap = new SolverBitmap("Corner Map", staticAnalysis.WallMap.Size);

            // No need to check the first and last lines
            for (int cx = 1; cx < cornerMap.Size.Width - 1; cx++)
                for (int cy = 1; cy < cornerMap.Size.Height - 1; cy++)
                {
                    // Check TopLeft
                    if (CheckCorner(staticAnalysis, new VectorInt(cx, cy)))
                    {
                        // Corner found
                        cornerMap[cx, cy] = true;
                    }
                }

            return cornerMap;
        }
Esempio n. 3
0
 private void BuildInitialMoveMap()
 {
     initialMoveMap = new SolverBitmap("Initial Move Map", MapAnalysis.GenerateMoveMap(boundryMap, initialCrateMap, controller.Map.Player));
     initialMoveMap[controller.Map.Player] = true;
 }
Esempio n. 4
0
        /// <summary>
        /// Build the 'DeadMap' for all positions on which a crate will make the puzzle unsolvable
        /// </summary>
        private void BuildDeadMap()
        {
            // Perform Recess Analysis
            RecessAnalysis recessAnalysis = new RecessAnalysis();
            Bitmap TMPrecessMap;

            // Corners
            cornerMap = recessAnalysis.FindCorners(this);

            // Recesses
            recessAnalysis.FindRecesses(this, out recesses, out TMPrecessMap);
            recessMap = new SolverBitmap("RecessMap", TMPrecessMap);

            // Build Dead Map
            deadMapAnalysis = new DeadMapAnalysis(this);
            DeadMapState deadMapResult = deadMapAnalysis.BuildDeadMap(null, goalMap, wallMap);
            deadMap = deadMapResult;

            // TODO: This is a little rough, it needs to be reworked into 'DynamicPreProcesses' or similar
            DeadMapAnalysis.LateRuleInit();
        }
Esempio n. 5
0
        /// <summary>
        /// Build a map of all unreachable positions (void + wall, etc)
        /// </summary>
        private void BuildBoundryMap()
        {
            // Make a simple boundry map
            Bitmap simpleBoundry = controller.Map.ToBitmap(CellStates.Wall);
            simpleBoundry = simpleBoundry.BitwiseOR(controller.Map.ToBitmap(CellStates.Void));

            // Create the AccessMap, all areas the player can go.
            FloodFillStrategy result = FloodFillStrategy.Evaluate(simpleBoundry, controller.Map.Player);
            accessMap = new SolverBitmap("AccessMap", result.Result);
            accessMap[controller.Map.Player] = true;
            controller.DebugReport.Append("AccessMap:");
            controller.DebugReport.Append(accessMap.ToString());

            floorMap = accessMap;

            // Correct/Full boundry is the reverse of the access map
            boundryMap = new SolverBitmap("Boundry", accessMap.BitwiseNOT());
            controller.DebugReport.Append("BoundryMap:");
            controller.DebugReport.Append(boundryMap.ToString());
        }
Esempio n. 6
0
        /// <summary>
        /// Set the simple maps, walls, etc
        /// </summary>
        private void BuildAdjustedCellMaps()
        {
            // Wall Map <-> boundry map
            wallMap = new SolverBitmap("BoundryWall Map", boundryMap);

            // Goal Map
            Bitmap tgoal = controller.Map.ToBitmap(CellStates.FloorGoal);
            tgoal = tgoal.BitwiseOR(controller.Map.ToBitmap(CellStates.FloorGoalCrate));
            tgoal = tgoal.BitwiseOR(controller.Map.ToBitmap(CellStates.FloorGoalPlayer));
            tgoal = tgoal.BitwiseAND(accessMap); // Must be accessable
            goalMap = new SolverBitmap("Goal Map", tgoal);

            // Crate Map
            Bitmap tcrate = controller.Map.ToBitmap(CellStates.FloorCrate);
            tcrate = tcrate.BitwiseOR(controller.Map.ToBitmap(CellStates.FloorGoalCrate));
            tcrate = tcrate.BitwiseAND(accessMap); // Must be accessable
            initialCrateMap = new SolverBitmap("Initial Crate Map", tcrate);
        }