Beispiel #1
0
        public UInt32 RollDice(DIE dieType, UInt32 dieQty, MODE rollMode)
        {
            UInt32 retval = 0;

            UInt32[] dieRollVals = new UInt32[dieQty];

            for (UInt32 i = 0; i < dieQty; i++)
            {
                dieRollVals[i] = RollDie(dieType);
                if (rollMode == MODE.REROLL_ONES && dieRollVals[i] == 1)
                {
                    while (dieRollVals[i] == 1)
                    {
                        dieRollVals[i] = RollDie(dieType);
                    }
                }
                retval += dieRollVals[i];
            }

            if (rollMode == MODE.HIGHEST_ONLY)
            {
                retval = dieRollVals.Max();
            }
            if (rollMode == MODE.LOWEST_ONLY)
            {
                retval = dieRollVals.Min();
            }
            return(retval);
        }
Beispiel #2
0
        public void BilinearResamplingAlgorithmComputeTest()
        {
            BilinearResamplingAlgorithm algorithm = new BilinearResamplingAlgorithm(_rasterMock.Object);

            UInt32[] values = new UInt32[4];

            for (Double rowIndex = 0; rowIndex < _rasterMock.Object.NumberOfRows; rowIndex += 0.1)
            {
                for (Double columnIndex = 0; columnIndex < _rasterMock.Object.NumberOfColumns; columnIndex += 0.1)
                {
                    Int32 rowFloor    = (Int32)Math.Floor(rowIndex);
                    Int32 columnFloor = (Int32)Math.Floor(columnIndex);

                    for (Int32 bandIndex = 0; bandIndex < _rasterMock.Object.NumberOfBands; bandIndex++)
                    {
                        values[0] = _rasterMock.Object.GetBoxedValue(rowFloor, columnFloor, bandIndex);
                        values[1] = _rasterMock.Object.GetBoxedValue(rowFloor, columnFloor + 1, bandIndex);
                        values[2] = _rasterMock.Object.GetBoxedValue(rowFloor + 1, columnFloor, bandIndex);
                        values[3] = _rasterMock.Object.GetBoxedValue(rowFloor + 1, columnFloor + 1, bandIndex);

                        UInt32 value = algorithm.Compute(rowIndex, columnIndex, bandIndex);

                        Assert.LessOrEqual(value, values.Max());
                        Assert.GreaterOrEqual(value, values.Min());
                    }
                }
            }
        }