Build() public method

public Build ( bool creatures ) : void
creatures bool
return void
コード例 #1
0
        public void BuildTest()
        {
            var frequency = 10;
            var eatMatrix = new FoodMatrix(2, 2, new FillingOfEntireFieldStrategy(frequency));
            var creatures = new bool[2, 2];

            for (int k = 0; k < 10; k++)
            {
                if (k != 9 && FoodMatrixConstants.AddedFoodLevel <= FoodMatrixConstants.MaxFoodLevel)
                {
                    eatMatrix.Build(creatures);
                    for (int i = 0; i < eatMatrix.Length; i++)
                        for (int j = 0; j < eatMatrix.Height; j++)
                            Assert.IsFalse(eatMatrix.HasMaxFoodLevel(new Point(i, j)));
                }

                if (k == 9)
                {
                    FrequentlyUsedMethods.RaiseFoodLevelToConstantWithBuild(eatMatrix, creatures, FoodMatrixConstants.MaxFoodLevel, frequency);
                    for (int i = 0; i < eatMatrix.Length; i++)
                        for (int j = 0; j < eatMatrix.Height; j++)
                            Assert.IsTrue(eatMatrix.HasMaxFoodLevel(new Point(i, j)));
                }
            }
        }
コード例 #2
0
        public void BuildIsFullTest()
        {
            var eatMatrix = new FoodMatrix(2, 2, new FillingFromCornersByWavesStrategy());
            var creatures = new bool[2, 2];

            eatMatrix.Build(creatures);
            for (int i = 0; i < eatMatrix.Length; i++)
                for (int j = 0; j < eatMatrix.Height; j++)
                    Assert.IsTrue(eatMatrix.HasMaxFoodLevel(new Point(i, j)), "Your MaxFoodLevel constant exceeds AddedFoodLevel multiplied by 4");
        }
コード例 #3
0
        public static void RaiseFoodLevelToConstantWithBuild(FoodMatrix eatMatrix, bool[,] creatures, int constant, int frequency)
        {
            var counter = 0;
            var i = 0;

            while (counter < constant)
            {
                eatMatrix.Build(creatures);
                if (i % frequency == 0)
                    counter += FoodMatrixConstants.AddedFoodLevel;
                i++;
            }
        }
コード例 #4
0
        public void BuildIsEmptyTest()
        {
            var eatMatrix = new FoodMatrix(2, 2, new FillingFromCornersByWavesStrategy());
            var creatures = new bool[2, 2];

            for (int i = 0; i < eatMatrix.Length; i++)
                for (int j = 0; j < eatMatrix.Height; j++)
                    creatures[i, j] = true;

            eatMatrix.Build(creatures);
            for (int i = 0; i < eatMatrix.Length; i++)
                for (int j = 0; j < eatMatrix.Height; j++)
                    Assert.IsFalse(eatMatrix.HasOneBite(new Point(i, j)));
        }