Ejemplo n.º 1
0
        public static IBitmap FindDoors(StaticAnalysisMaps staticMaps)
        {
            var res = new Bitmap(staticMaps.FloorMap.Size);

            foreach (var floor in staticMaps.FloorMap.TruePositions())
            {
                if (staticMaps.CornerMap[floor])
                {
                    continue;                              // Corners cannot be doors
                }
                // #.#
                if (staticMaps.WallMap[floor + VectorInt2.Left] && staticMaps.WallMap[floor + VectorInt2.Right])
                {
                    res[floor] = true;
                }

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

            return(res);
        }
Ejemplo n.º 2
0
        public static IBitmap FindDeadMap(StaticAnalysisMaps staticMaps)
        {
            var dead = new Bitmap(staticMaps.FloorMap.Size);

            // All corners are dead (provided no goals)
            foreach (var corner in staticMaps.CornerMap.TruePositions())
            {
                if (!staticMaps.GoalMap[corner])
                {
                    dead[corner] = true;
                }
            }

            // All recesses are dead (provided no goals)
            foreach (var recess in staticMaps.RecessMaps)
            {
                if (!recess.Intersects(staticMaps.GoalMap))
                {
                    foreach (var cc in recess.TruePositions())
                    {
                        dead[cc] = true;
                    }
                }
            }

            return(dead);
        }
Ejemplo n.º 3
0
        public static List <LineBitmap> FindWalls(StaticAnalysisMaps staticMaps)
        {
            var cornerAndSide = staticMaps.CornerMap.BitwiseOR(staticMaps.SideMap);
            var res           = new List <LineBitmap>();

            res.AddRange(FindRunsHorx(cornerAndSide));
            res.AddRange(FindRunsVert(cornerAndSide));


            return(res);
        }
Ejemplo n.º 4
0
        public static Map <float> CalculateWeightings(StaticAnalysisMaps input)
        {
            const float goal       = 999;
            const float cornergoal = 1.2f;
            var         res        = input.GoalMap.ToMap(goal, 0);

            foreach (var corner in input.CornerMap.TruePositions())
            {
                if (res[corner] > 0)
                {
                    res[corner] *= cornergoal;
                }
            }

            res = AverageOver(res, input.FloorMap, input.GoalMap);
            foreach (var dead in input.DeadMap.TruePositions())
            {
                res[dead] = -1;
            }
            return(res);
        }
Ejemplo n.º 5
0
 public PuzzleAnalysis(Puzzle start)
 {
     Start  = start;
     Static = new  StaticAnalysisMaps(start);
 }
Ejemplo n.º 6
0
 public static List <LineBitmap> FindRecesses(StaticAnalysisMaps staticMaps) =>
 staticMaps.IndividualWalls
 .Where(x => staticMaps.CornerMap[x.Start] && staticMaps.CornerMap[x.End])
 .ToList();