private static void PlaceRoom(IMap map, Room room)
        {
            int bestRoomScore = short.MaxValue;
            MapCell cellToPlace = null;

            foreach (var cell in map)
            {
                // place rooms only in corridors to ensure it has exit
                if (!cell.IsCorridor)
                    continue;

                var newBounds = new Rectangle(
                    cell.Location.X,
                    cell.Location.Y,
                    room.Width,
                    room.Height);
                if (!map.Bounds.Contains(newBounds))
                    continue;

                var roomScore = CalculateRoomScore(room, map, cell);
                if (bestRoomScore > roomScore)
                {
                    cellToPlace = cell;
                    bestRoomScore = roomScore;
                }
            }

            if (cellToPlace != null)
            {
                map.InsertRoom(room, cellToPlace.Location);
            }
        }