コード例 #1
0
 private _Model MergeRooms(_Model mMod, _Room room, _Room modelRoom)
 {
     //Model m = mMod.DeepCopy();
     mMod = RemoveCommonWalls(mMod, room, modelRoom);
     //MergeBoundaryLineListToSmallerIdRooms();
     return(m);
 }
コード例 #2
0
        private _Model RemoveCommonWalls(_Model m, _Room room1, _Room room2)
        {
            List <_Line> common = room1.Lines.Intersect(room2.Lines).ToList();

            foreach (_Line line in common)
            {
                room1.Lines.Remove(line);
                room2.Lines.Remove(line);
            }
            room1.Lines.AddRange(room2.Lines);
            room2.Lines.AddRange(room1.Lines);

            int  result1 = room1.Number;
            int  result2 = room2.Number;
            bool parsed1 = room1.Number is int;
            bool parsed2 = room2.Number is int;

            if (parsed1 && parsed2 && result1 < result2)
            {
                m.rooms.Remove(room2);
            }
            else
            {
                m.rooms.Remove(room1);
            }

            return(m);
        }
コード例 #3
0
        public List <_Model> AllRoomPairs(_Model m_mod)
        {
            List <_Model> returnList = new List <_Model>();

            for (var i = 0; i < m_mod.rooms.Count; i++)
            {
                _Room room = m_mod.rooms[i];
                for (var j = i + 1; j < m_mod.rooms.Count; j++)
                {
                    _Room modelRoom = m_mod.rooms[j];
                    //if (room2.Guid == room1.Guid) continue;

                    bool a = DoTheyHaveCommmonWall(room, modelRoom);
                    if (!a)
                    {
                        continue;
                    }

                    else
                    {
                        _Room  room2;
                        _Room  modelRoom2;
                        _Model m_mod2 = m_mod.DeepCopy(room, modelRoom, out room2, out modelRoom2);

                        _Model newModel = MergeRooms(m_mod2, room2, modelRoom2);
                        returnList.Add(newModel);
                    }
                }
            }

            return(returnList);
        }
コード例 #4
0
ファイル: Action.cs プロジェクト: kasznare/DIP1
 //public Switch(ref _Room r1, ref _Room r2, double cost) {
 //    this.r1 = r1;
 //    this.r2 = r2;
 //    this.cost = cost;
 //}
 public Switch(ref _Room r1, ref _Room r2, Cost cost)
 {
     this.r1   = r1;
     this.r2   = r2;
     this.cost = cost.SummaryCost;
     Cost      = cost;
 }
コード例 #5
0
        private void CalculateSwitchCosts()
        {
            int rooms = Model.rooms.Count;

            for (int index = 0; index < rooms; index++)
            {
                for (int secondindex = index + 1; secondindex < rooms; secondindex++)
                {
                    _Room  r1        = Model.rooms.ElementAt(index);
                    _Room  r2        = Model.rooms.ElementAt(secondindex);
                    _Model tempModel = Model.DeepCopy(r1, r2, out _Room r1target, out _Room r2target);
                    tempModel.SwitchRooms(ref r1target, ref r2target);
                    if (tempModel.IsInInvalidState)
                    {
                        continue;
                    }

                    Cost cost = CostCalculationService.CalculateCostNew(tempModel);
                    lock (locker)
                    {
                        Actions.Add(new Switch(ref r1, ref r2, cost));
                    }
                }
            }
        }
コード例 #6
0
ファイル: Map.cs プロジェクト: jedrak/UndeadRedRevolver
    // Start is called before the first frame update
    void Start()
    {
        _generator         = GetComponent <RoomGenerator>();
        map                = new _Room[rows, columns];
        _playerX           = 0;
        _playerY           = 0;
        _playerRoomChanged = true;

        for (int i = 0; i < rows; i++)
        {
            for (int j = 0; j < columns; j++)
            {
                map[i, j] = new _Room();
                map[i, j].generate();
            }
        }
        for (int i = 0; i < nrOfEmptyRooms; i++)
        {
            int roomX = Random.Range(1, columns);
            int roomY = Random.Range(1, rows);
            //Debug.Log("X: "+roomX + " Y: "+roomY);
            map[roomX, roomY].empty = true;
        }
        _chestHandle();
        _respawnHandle();
    }
コード例 #7
0
 private bool DoTheyHaveCommmonWall(_Room room, _Room modelRoom)
 {
     if (room.Lines.Intersect(modelRoom.Lines).Any())
     {
         return(true);
     }
     return(false);
 }
コード例 #8
0
        public static _Model InitSimpleModel()
        {
            _Model m = new _Model();

            _Point q1    = new _Point(100, 0);
            _Point q2    = new _Point(400, 0);
            _Point p1    = new _Point(100, 100);
            _Point p2    = new _Point(400, 100);
            _Point p3    = new _Point(400, 400);
            _Point p4    = new _Point(100, 400);
            _Line  line1 = new _Line(p1, p2);
            _Line  line2 = new _Line(p2, p3);
            _Line  line3 = new _Line(p3, p4);
            _Line  line4 = new _Line(p4, p1);
            _Line  l1    = new _Line(q1, p1);
            _Line  l2    = new _Line(q2, p2);
            _Line  l3    = new _Line(q1, q2);
            _Room  first = new _Room {
                Name = "FirstRoom", Number = 1, type = _RoomType.Kitchen
            };
            _Room second = new _Room {
                Name = "SecondRoom", Number = 2, type = _RoomType.LivingRoom, isStartRoom = true
            };

            first.Lines  = (new List <_Line>()
            {
                line1, line2, line3, line4
            });
            second.Lines = (new List <_Line>()
            {
                l1, l2, l3, line1
            });

            m.rooms.Add(first);
            m.rooms.Add(second);

            foreach (var room in m.rooms)
            {
                room.CanGetBoundarySorted();
            }

            //List<_Point> boundaries = new List<_Point>() { new _Point(50, 0), new _Point(50, 50), new _Point(0, 50), new _Point(0, 500), new _Point(500, 500), new _Point(500, 0) };
            //List<_Point> boundaries = new List<_Point>() { new _Point(-10, -10),  new _Point(-10, 500), new _Point(500, 500), new _Point(500, -10) };
            List <_Point> boundaries = new List <_Point>()
            {
                new _Point(-10, -10), new _Point(-10, 800), new _Point(500, 800), new _Point(500, -10)
            };

            m.OutlinePolygonPoints = boundaries;
            List <System.Windows.Point> convertedPointsForPolygon = boundaries.Select(i => new System.Windows.Point(i.X, i.Y)).ToList();

            m.AvailableOutlinePolygon = new Polygon()
            {
                Points = new PointCollection(convertedPointsForPolygon)
            };

            return(m);
        }
コード例 #9
0
        private void RoomGrid_OnSelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            _Room index = RoomGrid.CurrentCell.Item as _Room;

            selectedLineIndices.Clear();
            selectedLines.Clear();
            var i = 0;

            foreach (var line in Lines)
            {
                if (index != null && index.Lines.Contains(line))
                {
                    selectedLineIndices.Add(i);
                    selectedLines.Add(line);
                }
                i++;
            }
            Paint();
            RoomGrid.SelectedIndex = -1;
        }
コード例 #10
0
        public static _Model InitSimplestModel()
        {
            _Model m     = new _Model();
            _Point p1    = new _Point(100, 100);
            _Point p2    = new _Point(400, 100);
            _Point p3    = new _Point(400, 400);
            _Point p4    = new _Point(100, 400);
            _Line  line1 = new _Line(p1, p2);
            _Line  line2 = new _Line(p2, p3);
            _Line  line3 = new _Line(p3, p4);
            _Line  line4 = new _Line(p4, p1);
            _Room  _Room = new _Room {
                Name = "FirstRoom", Number = 1, type = _RoomType.LivingRoom, isStartRoom = true
            };

            _Room.Lines = (new List <_Line>()
            {
                line1, line2, line3, line4
            });
            m.rooms.Add(_Room);
            foreach (var room in m.rooms)
            {
                room.CanGetBoundarySorted();
            }

            List <_Point> boundaries = new List <_Point>()
            {
                new _Point(0, 0), new _Point(0, 450), new _Point(450, 450), new _Point(450, 0)
            };

            m.OutlinePolygonPoints = boundaries;
            List <System.Windows.Point> convertedPointsForPolygon = boundaries.Select(i => new System.Windows.Point(i.X, i.Y)).ToList();

            m.AvailableOutlinePolygon = new Polygon()
            {
                Points = new PointCollection(convertedPointsForPolygon)
            };
            return(m);
        }
コード例 #11
0
        public static _Model InitTestModel()
        {
            _Model m = new _Model();

            _Point a1 = new _Point(0, 0);
            _Point a2 = new _Point(0, 100);
            _Point a3 = new _Point(0, 200);
            _Point a4 = new _Point(0, 300);

            _Point a5 = new _Point(100, 0);
            _Point a6 = new _Point(100, 100);
            _Point a7 = new _Point(100, 200);
            _Point a8 = new _Point(100, 300);

            _Point a9  = new _Point(200, 0);
            _Point a10 = new _Point(200, 100);
            _Point a11 = new _Point(200, 200);
            _Point a12 = new _Point(200, 300);

            _Point a13 = new _Point(300, 0);
            _Point a14 = new _Point(300, 100);
            _Point a15 = new _Point(300, 200);
            _Point a16 = new _Point(300, 300);



            _Line l12 = new _Line(a1, a2);
            _Line l23 = new _Line(a2, a3);
            _Line l34 = new _Line(a3, a4);

            _Line l56 = new _Line(a5, a6);
            _Line l67 = new _Line(a6, a7);
            _Line l78 = new _Line(a7, a8);

            _Line l910  = new _Line(a9, a10);
            _Line l1011 = new _Line(a10, a11);
            _Line l1112 = new _Line(a11, a12);

            _Line l1314 = new _Line(a13, a14);
            _Line l1415 = new _Line(a14, a15);
            _Line l1516 = new _Line(a15, a16);


            _Line l15  = new _Line(a1, a5);
            _Line l59  = new _Line(a5, a9);
            _Line l913 = new _Line(a9, a13);

            _Line l26  = new _Line(a2, a6);
            _Line l610 = new _Line(a6, a10);

            l610.Name = "key";
            _Line l1014 = new _Line(a10, a14);

            _Line l37   = new _Line(a3, a7);
            _Line l711  = new _Line(a7, a11);
            _Line l1115 = new _Line(a11, a15);

            _Line l48   = new _Line(a4, a8);
            _Line l812  = new _Line(a8, a12);
            _Line l1216 = new _Line(a12, a16);

            _Room first = new _Room {
                Name = "FirstRoom", Number = 1, type = _RoomType.Kitchen
            };
            _Room second = new _Room {
                Name = "SecondRoom", Number = 1, type = _RoomType.LivingRoom
            };
            _Room third = new _Room {
                Name = "ThirdRoom", Number = 1, type = _RoomType.CorridorRoom
            };
            _Room fourth = new _Room {
                Name = "FourthRoom", Number = 1, type = _RoomType.RestRoom
            };
            _Room fifth = new _Room {
                Name = "fifthRoom", Number = 1, type = _RoomType.BedRoom
            };
            _Room sixth = new _Room {
                Name = "sixthRoom", Number = 1, type = _RoomType.BedRoom
            };
            _Room seventh = new _Room {
                Name = "seventhRoom", Number = 1, type = _RoomType.BedRoom
            };
            _Room eight = new _Room {
                Name = "eightRoom", Number = 1, type = _RoomType.BedRoom
            };
            _Room nineth = new _Room {
                Name = "ninethRoom", Number = 1, type = _RoomType.BedRoom
            };;

            second.isStartRoom = true;


            first.Lines   = (new List <_Line>()
            {
                l12, l26, l56, l15
            });
            second.Lines  = (new List <_Line>()
            {
                l23, l37, l67, l26
            });
            third.Lines   = (new List <_Line>()
            {
                l34, l48, l78, l37
            });
            fourth.Lines  = (new List <_Line>()
            {
                l56, l610, l910, l59
            });
            fifth.Lines   = (new List <_Line>()
            {
                l67, l711, l1011, l610
            });
            sixth.Lines   = (new List <_Line>()
            {
                l78, l812, l1112, l711
            });
            seventh.Lines = (new List <_Line>()
            {
                l910, l1014, l1314, l913
            });
            eight.Lines   = (new List <_Line>()
            {
                l1011, l1115, l1415, l1014
            });
            nineth.Lines  = (new List <_Line>()
            {
                l1112, l1216, l1115, l1516
            });


            m.rooms.Add(first);
            m.rooms.Add(second);
            m.rooms.Add(third);
            m.rooms.Add(fourth);
            m.rooms.Add(fifth);
            m.rooms.Add(sixth);
            m.rooms.Add(seventh);
            m.rooms.Add(eight);
            m.rooms.Add(nineth);

            foreach (var room in m.rooms)
            {
                room.CanGetBoundarySorted();
            }

            return(m);
        }
コード例 #12
0
        public static _Model InitTwoLevelModel()
        {
            _Model m = new _Model();

            _Point a1 = new _Point(0, 0);
            _Point a2 = new _Point(0, 100);
            _Point a3 = new _Point(0, 200);
            _Point a4 = new _Point(0, 300);

            _Point a5 = new _Point(100, 0);
            _Point a6 = new _Point(100, 100);
            _Point a7 = new _Point(100, 200);
            _Point a8 = new _Point(100, 300);

            _Point a9  = new _Point(200, 0);
            _Point a10 = new _Point(200, 100);
            _Point a11 = new _Point(200, 200);
            _Point a12 = new _Point(200, 300);

            _Point a13 = new _Point(300, 0);
            _Point a14 = new _Point(300, 100);
            _Point a15 = new _Point(300, 200);
            _Point a16 = new _Point(300, 300);



            _Line l12 = new _Line(a1, a2);
            _Line l23 = new _Line(a2, a3);
            _Line l34 = new _Line(a3, a4);

            _Line l56 = new _Line(a5, a6);
            _Line l67 = new _Line(a6, a7);
            _Line l78 = new _Line(a7, a8);

            _Line l910  = new _Line(a9, a10);
            _Line l1011 = new _Line(a10, a11);
            _Line l1112 = new _Line(a11, a12);

            _Line l1314 = new _Line(a13, a14);
            _Line l1415 = new _Line(a14, a15);
            _Line l1516 = new _Line(a15, a16);


            _Line l15  = new _Line(a1, a5);
            _Line l59  = new _Line(a5, a9);
            _Line l913 = new _Line(a9, a13);

            _Line l26  = new _Line(a2, a6);
            _Line l610 = new _Line(a6, a10);

            l610.Name = "key";
            _Line l1014 = new _Line(a10, a14);

            _Line l37   = new _Line(a3, a7);
            _Line l711  = new _Line(a7, a11);
            _Line l1115 = new _Line(a11, a15);

            _Line l48   = new _Line(a4, a8);
            _Line l812  = new _Line(a8, a12);
            _Line l1216 = new _Line(a12, a16);

            _Room first = new _Room {
                Name = "FirstRoom", Number = 1, type = _RoomType.Kitchen
            };
            _Room second = new _Room {
                Name = "SecondRoom", Number = 2, type = _RoomType.LivingRoom
            };
            _Room third = new _Room {
                Name = "ThirdRoom", Number = 3, type = _RoomType.CorridorRoom
            };
            _Room fourth = new _Room {
                Name = "FourthRoom", Number = 4, type = _RoomType.DiningRoom
            };
            _Room fifth = new _Room {
                Name = "FifthRoom", Number = 5, type = _RoomType.StairCase
            };
            _Room sixth = new _Room {
                Name = "SixthRoom", Number = 6, type = _RoomType.RestRoom
            };
            _Room seventh = new _Room {
                Name = "SeventhRoom", Number = 7, type = _RoomType.BedRoom
            };
            _Room eight = new _Room {
                Name = "EightRoom", Number = 8, type = _RoomType.BedRoom
            };
            _Room nineth = new _Room {
                Name = "NinethRoom", Number = 9, type = _RoomType.BedRoom
            };;

            second.isStartRoom = true;


            first.Lines   = (new List <_Line>()
            {
                l12, l26, l56, l15
            });
            second.Lines  = (new List <_Line>()
            {
                l23, l37, l67, l26
            });
            third.Lines   = (new List <_Line>()
            {
                l34, l48, l78, l37
            });
            fourth.Lines  = (new List <_Line>()
            {
                l56, l610, l910, l59
            });
            fifth.Lines   = (new List <_Line>()
            {
                l67, l711, l1011, l610
            });
            sixth.Lines   = (new List <_Line>()
            {
                l78, l812, l1112, l711
            });
            seventh.Lines = (new List <_Line>()
            {
                l910, l1014, l1314, l913
            });
            eight.Lines   = (new List <_Line>()
            {
                l1011, l1115, l1415, l1014
            });
            nineth.Lines  = (new List <_Line>()
            {
                l1112, l1216, l1115, l1516
            });


            m.rooms.Add(first);
            m.rooms.Add(second);
            m.rooms.Add(third);
            m.rooms.Add(fourth);
            m.rooms.Add(fifth);
            m.rooms.Add(sixth);
            m.rooms.Add(seventh);
            m.rooms.Add(eight);
            m.rooms.Add(nineth);

            foreach (var room in m.rooms)
            {
                room.CanGetBoundarySorted();
            }

            List <_Point> boundaries = new List <_Point>()
            {
                new _Point(-10, -10), new _Point(-10, 600), new _Point(400, 600), new _Point(400, -10)
            };

            m.OutlinePolygonPoints = boundaries;
            List <System.Windows.Point> convertedPointsForPolygon = boundaries.Select(i => new System.Windows.Point(i.X, i.Y)).ToList();

            m.AvailableOutlinePolygon = new Polygon()
            {
                Points = new PointCollection(convertedPointsForPolygon)
            };

            return(m);
        }
コード例 #13
0
        public static _Model InitNormalModel()
        {
            _Model m  = new _Model();
            _Point a1 = new _Point(0, 0);
            _Point a2 = new _Point(200, 0);
            _Point a3 = new _Point(200, 200);
            _Point a4 = new _Point(0, 200);

            _Point a5 = new _Point(200, 400);
            _Point a6 = new _Point(0, 400);
            _Point a7 = new _Point(400, 0);
            _Point a8 = new _Point(400, 200);
            _Point a9 = new _Point(400, 400);

            _Line l12 = new _Line(a1, a2);
            _Line l23 = new _Line(a2, a3);
            _Line l34 = new _Line(a3, a4);
            _Line l41 = new _Line(a4, a1);

            _Line l35 = new _Line(a3, a5);
            _Line l56 = new _Line(a5, a6);
            _Line l64 = new _Line(a6, a4);

            _Line l27 = new _Line(a2, a7);
            _Line l78 = new _Line(a7, a8);
            _Line l83 = new _Line(a8, a3);

            _Line l89 = new _Line(a8, a9);
            _Line l95 = new _Line(a9, a5);


            _Room first = new _Room {
                Name = "FirstRoom", Number = 1, type = _RoomType.Kitchen
            };
            _Room second = new _Room {
                Name = "SecondRoom", Number = 2, type = _RoomType.LivingRoom
            };
            _Room third = new _Room {
                Name = "ThirdRoom", Number = 3, type = _RoomType.BedRoom
            };
            _Room fourth = new _Room {
                Name = "FourthRoom", Number = 4, type = _RoomType.RestRoom
            };

            first.Lines  = (new List <_Line>()
            {
                l12, l23, l34, l41
            });
            second.Lines = (new List <_Line>()
            {
                l35, l56, l64, l34
            });
            third.Lines  = (new List <_Line>()
            {
                l23, l27, l78, l83
            });
            fourth.Lines = (new List <_Line>()
            {
                l83, l89, l95, l35
            });

            m.rooms.Add(first);
            m.rooms.Add(second);
            m.rooms.Add(third);
            m.rooms.Add(fourth);
            foreach (var room in m.rooms)
            {
                room.CanGetBoundarySorted();
            }
            return(m);
        }
コード例 #14
0
        private static double CalculateDoorCost()
        {
            //bejárhatóság
            double cost = 0.0;
            //Dictionary<int, List<_Room>> processedRooms = new Dictionary<int, List<_Room>>();

            //int accessRoomDepth = 0;
            //List<_Room> actualRooms = localModel.rooms.Where(i => i.isStartRoom).ToList();
            //processedRooms.Add(accessRoomDepth, actualRooms);

            int doorCount = 0;

            foreach (_Room room in localModel.rooms)
            {
                foreach (_Line roomLine in room.Lines)
                {
                    if (roomLine.HasDoor)
                    {
                        doorCount++;
                    }
                }
            }

            cost += doorCount * 100;

            if (doorCount > localModel.rooms.Count)
            {
                cost += Math.Pow(2, doorCount - localModel.rooms.Count);
            }
            //TODO: dikhstra

            for (var i = 0; i < localModel.rooms.Count; i++)
            {
                _Room room  = localModel.rooms[i];
                int   depth = localModel.DepthMatrix[i];
                if (room.type.privacy > depth && depth < 100)
                {
                    cost += Math.Pow(2, room.type.privacy - depth);
                }

                if (depth > 100)
                {
                    cost += 1000000;
                }
            }
            //todo: what if unreachable? check it! that is bad.

            //bejárhatóságra ez elég
            //már feldolgozott elemek
            //éppen feldolgozás alatt állló elemek
            //szaggatott lsita az éppen szomszédokról

            //szomszédossági mátrix n-n - át lehet-e menni, és milyen költséggel
            //bellmann ford, floyd, dijkstra


            //while (accessRoomDepth < localModel.modelRooms.Count) {
            //    List<MyRoom> actualRoomsForThisDepth = new List<MyRoom>();
            //    bool isOnGoing = processedRooms.TryGetValue(accessRoomDepth, out actualRoomsForThisDepth);
            //    if (!isOnGoing) break;

            //    accessRoomDepth++;
            //    foreach (MyRoom room in actualRoomsForThisDepth) {
            //        foreach (MyLine line in room.BoundaryLines) {
            //            if (line.HasOpening) {
            //                List<MyRoom> reachableRoomsFromThisLine = line.relatedRooms;
            //                reachableRoomsFromThisLine.Remove(room);

            //                List<MyRoom> alreadyInRoomsAtThisDepth = new List<MyRoom>();
            //                bool isAlready = processedRooms.TryGetValue(accessRoomDepth, out alreadyInRoomsAtThisDepth);

            //                if (isAlready) {
            //                    reachableRoomsFromThisLine.AddRange(alreadyInRoomsAtThisDepth);
            //                    processedRooms.Remove(accessRoomDepth);
            //                }
            //                processedRooms.Add(accessRoomDepth, reachableRoomsFromThisLine);
            //            }
            //        }
            //    }
            //}
            //van-e helyiség ami kimarad, ekkor hozzáadjuk az area-t a költséghez
            //helyiség privacy gradientje megfelel-e
            //megfelelő szobák egymásból nyílnak-e

            //külső vonal változtatás nem változtat bejárhatóságot

            return(cost);
        }
コード例 #15
0
ファイル: Action.cs プロジェクト: kasznare/DIP1
 public Switch(ref _Room r1, ref _Room r2)
 {
     this.r1 = r1;
     this.r2 = r2;
 }
コード例 #16
0
        private static double CalculateConstraintCost()
        {
            double        asd         = 0.0;
            List <_Point> boundaries2 = localModel.OutlinePolygonPoints;

            if (boundaries2 == null || (boundaries2 != null && !boundaries2.Any()))
            {
                return(asd);
            }

            List <C2DPoint> convertedPointsForPolygon3 = boundaries2.Select(i => new C2DPoint(i.X, i.Y)).ToList();
            C2DPolygon      BoundaryPolygon            = new C2DPolygon();

            BoundaryPolygon.Create(convertedPointsForPolygon3, true);

            foreach (_Room room in localModel.rooms)
            {
                List <_Point> boundaries = room.GetPoints();
                if (!boundaries.Any())
                {
                    continue;
                }
                List <C2DPoint> convertedPointsForPolygon2 = boundaries.Select(i => new C2DPoint(i.X, i.Y)).ToList();

                C2DPolygon roomPolygon = new C2DPolygon();
                roomPolygon.Create(convertedPointsForPolygon2, true);
                room.Polygon = roomPolygon;
                CGrid grid = new CGrid();
                List <C2DHoledPolygon> asdasd = new List <C2DHoledPolygon>();
                roomPolygon.GetOverlaps(BoundaryPolygon, asdasd, grid);
                List <double> a          = asdasd.Select(i => i.GetArea()).ToList();
                double        sumoverlap = a.Sum() / 10000;
                double        actualArea = room.Area;
                if (actualArea - sumoverlap > 0)
                {
                    asd += +10000000;
                }

                asd += Math.Pow(2, actualArea - sumoverlap);
            }

            for (var i = 0; i < localModel.rooms.Count; i++)
            {
                _Room modelRoom = localModel.rooms[i];
                for (int j = i + 1; j < localModel.rooms.Count; j++)
                {
                    _Room modelRoom2 = localModel.rooms[j];
                    CGrid grid       = new CGrid();
                    List <C2DHoledPolygon> asdasd = new List <C2DHoledPolygon>();
                    modelRoom.Polygon.GetOverlaps(modelRoom2.Polygon, asdasd, grid);
                    List <double> a          = asdasd.Select(k => k.GetArea()).ToList();
                    double        sumoverlap = a.Sum() / 10000;
                    double        actualArea = modelRoom.Area;
                    if (sumoverlap > 0)
                    {
                        asd += +10000000;
                    }
                }
            }

            //then avoid room overlaps

            return(asd);
        }
コード例 #17
0
        private static double CalculateLayoutCost()
        {
            double wallLength = 0.0;

            foreach (_Line seg in localModel.AllLinesFlat())
            {
                {
                    double d = seg.GetLength();
                    if (d > 0)
                    {
                        if (seg.relatedrooms.Count < 1)            //i need to calculate exterior walls with different cost
                        {
                            wallLength += Math.Sqrt((d / 100)) * 100;
                        }
                        else
                        {
                            wallLength += Math.Sqrt((d / 100)) * 3;
                        }
                    }

                    if (d < 30) //WE dont like small walls
                    {
                        wallLength += Math.Sqrt((d / 100)) * 10;
                    }
                }
            }



            //TODO: what rooms are adjacent?
            // |         |        |        |
            // |         |        |        |
            // |     2   |    1,3 |   2    |
            // |         |        |        |
            // |_________|________|________|
            //bellmann ford, dijktra
            //szomszédossági mátrix
            double layoutcost = 0.0;

            for (var i = 0; i < localModel.rooms.Count; i++)
            {
                _Room room = localModel.rooms[i];
                for (var j = i + 1; j < localModel.rooms.Count; j++)
                {
                    _Room localModelRoom = localModel.rooms[j];
                    if (localModel.AdjacencyMatrix[i, j] == 1)
                    {
                        layoutcost += RoomTypeCostStorage.FindCost(room.type, localModelRoom.type);
                    }
                }
            }

            //elrendezésszintű

            //ajtókat, nyílásokat letenni...(kérdés)
            //bejárhatóság generálás
            double privacygradientcost = 0.0;
            //kerületszámítás
            //minimális optimum kerület = sqrt(minden szoba area összege)*4
            double summary = privacygradientcost + wallLength + layoutcost;

            summary = Math.Round(summary, 2);
            return(summary);
        }