Exemple #1
0
        public IShapeConfigurator ConfigureGenerationStrategy(GenerationStrategy strategy)
        {
            GenerationStrategy = strategy;

            Logging.Instance.Write("[ShapeBuilder] Configured Generation Strategy", LoggingLevel.Pattern);

            return(this);
        }
Exemple #2
0
        /// <summary>
        /// Creates a new generation.
        /// </summary>
        /// <param name="chromosomes">The chromosomes for new generation.</param>
        public virtual void CreateNewGeneration(IList <IChromosome> chromosomes)
        {
            ExceptionHelper.ThrowIfNull("chromosomes", chromosomes);
            chromosomes.ValidateGenes();

            CurrentGeneration = new Generation(++GenerationsNumber, chromosomes);
            Generations.Add(CurrentGeneration);
            GenerationStrategy.RegisterNewGeneration(this);
        }
Exemple #3
0
        public void GenerateTableContent(GenerationStrategy <T> generationStrategy)
        {
            IList <T> content = generationStrategy();

            foreach (T elem in content)
            {
                adao.Create(elem);
            }
        }
 public EncryptionConfig(string stopCondStr = DEFAULT_STOP_COND_STR,
                         char encFlag       = DEFAULT_ENC_FLAG,
                         char decFlag       = DEFAULT_DEC_FLAG,
                         GenerationStrategy <EncryptionData> generationStrategy = null)
 {
     StopCondStr             = stopCondStr;
     EncFlag                 = encFlag;
     DecFlag                 = decFlag;
     this.generationStrategy = generationStrategy == null ? DefaultGenerationStrategy : generationStrategy;
 }
Exemple #5
0
        }                         // Needed for JSON deserialization

        /// <summary>
        /// Generate a shape somewhere in the given region using the provided strategy.
        /// CenterPos will be set to the position of the first generated ShapeBlock
        /// </summary>
        public BaseShape(GenerationStrategy strategy, int lowerBoundX, int lowerBoundY, int upperBoundX, int upperBoundY)
        {
            var blocks = strategy.GenerateShapeBlocks(lowerBoundX, lowerBoundY, upperBoundX, upperBoundY);

            CenterPosX       = blocks[0].OffsetX;
            CenterPosY       = blocks[0].OffsetY;
            this.lowerBoundY = lowerBoundY;
            this.upperBoundY = upperBoundY;
            ShapeBlocks      = GenerationStrategy.MakeRelative(blocks, CenterPosX, CenterPosY);
            Strategy         = strategy;
        }
Exemple #6
0
        /// <summary>
        /// Get the first out-of-bounds ShapeBlocks, which should be sent to client. Called by host.
        /// </summary>
        public override List <ShapeBlock> GetNextBlocks()
        {
            var nextBlock = ShapeBlocks.FirstOrDefault(x => x.OffsetX >= GameSettings.HorizontalCellCount);

            if (nextBlock is null)
            {
                // Generate blocks for the next screen
                var lastBlock = ShapeBlocks.Last();
                var blocks    = Strategy.GenerateShapeBlocks(lastBlock.OffsetX + 1, lowerBoundY, GameSettings.HorizontalCellCount * 2, upperBoundY, lastBlock.OffsetY + CenterPosY);
                nextBlock = blocks.First();
                ShapeBlocks.AddRange(GenerationStrategy.MakeRelative(blocks, CenterPosX, CenterPosY));
            }
            return(ShapeBlocks.Where(x => x.OffsetX == nextBlock.OffsetX).ToList());
        }
Exemple #7
0
        public override BaseShape CreateStaticShape(Shape shape, GenerationStrategy strategy, int lowerBoundX, int lowerBoundY, int upperBoundX, int upperBoundY)
        {
            Logging.Instance.Write("Abstract Factory -> ImpassableShapeFactory used (" + shape + ")");

            switch (shape)
            {
            case Shape.Platform:
                return(impassablePlatformBuilder
                       .Configure()
                       .ConfigureBounds(lowerBoundX, lowerBoundY, upperBoundX, upperBoundY)
                       .ConfigureGenerationStrategy(strategy)
                       .Build());

            default: throw new ArgumentException("Shape is not found");
            }
        }
        /// <summary>
        /// Counts a number of arguments needed for correct value generation
        /// </summary>
        /// <param name="strategy">Generation strategy</param>
        /// <returns>Integral number of arguments</returns>
        private static int ParamsLength(GenerationStrategy strategy)
        {
            var result = 1; // Constant is defined by 1 parameter

            switch (strategy)
            {
            case GenerationStrategy.Iterate:
                result = 3;     // From ... To ... Step ...
                break;

            case GenerationStrategy.Random:
                result = 2;     // From ... To ...
                break;
            }
            return(result);
        }
Exemple #9
0
 public abstract BaseShape CreateStaticShape(Shape shape, GenerationStrategy strategy, int lowerBoundX, int lowerBoundY, int upperBoundX, int upperBoundY);
Exemple #10
0
        }                                  // Needed for JSON deserialization

        public ImpassablePlatform(GenerationStrategy strategy, int lowerBoundX, int lowerBoundY, int upperBoundX, int upperBoundY)
            : base(strategy, lowerBoundX, lowerBoundY, upperBoundX, upperBoundY)
        {
        }
Exemple #11
0
 public EntityShape(GenerationStrategy strategy, int lowerBoundX, int lowerBoundY, int upperBoundX, int upperBoundY)
     : base(strategy, lowerBoundX, lowerBoundY, upperBoundX, upperBoundY)
 {
 }
 public VariableGeneratorMetadata(String name, GenerationStrategy strategy, params double[] parameters)
 {
     this.variableName = name;
     this.strategy     = strategy;
     this.parameters   = VerifyParameters(parameters);
 }