예제 #1
0
 public RoomContainer(RoomDescription roomDescription, List <Transformation> transformations, double probability, bool normalizeProbabilities)
 {
     RoomDescription        = roomDescription;
     Probability            = probability;
     NormalizeProbabilities = normalizeProbabilities;
     Transformations        = transformations;
 }
예제 #2
0
        /// <summary>
        /// Add a shape that will be used for corridor rooms.
        /// </summary>
        /// <param name="shape">Shape to add.</param>
        /// <param name="transformations">Allowed transformation of the shape.</param>
        /// <param name="probability">The probability of choosing a given shape.</param>
        /// <param name="normalizeProbabilities">Whether probabilities should be normalized after rotating shapes.</param>
        public virtual void AddCorridorShapes(RoomDescription shape, ICollection <Transformation> transformations = null, double probability = 1, bool normalizeProbabilities = true)
        {
            ThrowIfLocked();

            if (probability <= 0)
            {
                throw new ArgumentException("Probability should be greater than zero", nameof(probability));
            }

            if (RoomShapes.Any(x => shape.Equals(x.RoomDescription)))
            {
                throw new InvalidOperationException("Every RoomDescription can be added at most once");
            }

            if (transformations != null && transformations.Count == 0)
            {
                throw new ArgumentException("There must always be at least one transformation available (e.g. identity)");
            }

            var transformationsList = transformations == null ? null : new List <Transformation>(transformations);

            CorridorShapes.Add(new RoomContainer(shape, transformationsList, probability, normalizeProbabilities));
        }
예제 #3
0
        /// <summary>
        /// Add shape that will be used when choosing shapes for a given node.
        /// </summary>
        /// <param name="node"></param>
        /// <param name="shape">Shape to add.</param>
        /// <param name="transformations">Allowed transformation of the shape.</param>
        /// <param name="probability">The probability of choosing a given shape.</param>
        /// <param name="normalizeProbabilities">Whether probabilities should be normalized after rotating shapes.</param>
        public virtual void AddRoomShapes(TNode node, RoomDescription shape, ICollection <Transformation> transformations = null, double probability = 1, bool normalizeProbabilities = true)
        {
            ThrowIfLocked();

            if (probability <= 0)
            {
                throw new ArgumentException("Probability should be greater than zero", nameof(probability));
            }

            if (!Rooms.TryGetValue(node, out var alias))
            {
                throw new InvalidOperationException("Room must be first added to add shapes");
            }

            var roomShapesForNode = RoomShapesForNodes[alias];

            if (roomShapesForNode == null)
            {
                roomShapesForNode         = new List <RoomContainer>();
                RoomShapesForNodes[alias] = roomShapesForNode;
            }

            if (roomShapesForNode.Any(x => shape.Equals(x.RoomDescription)))
            {
                throw new InvalidOperationException("Every RoomDescription can be added at most once");
            }

            if (transformations != null && transformations.Count == 0)
            {
                throw new ArgumentException("There must always be at least one transformation available (e.g. identity)");
            }

            var transformationsList = transformations == null ? null : new List <Transformation>(transformations);

            roomShapesForNode.Add(new RoomContainer(shape, transformationsList, probability, normalizeProbabilities));
        }