예제 #1
0
        public void Incomplete()
        {
            int numSamples = 3;
            var sampler    = new CurrentTetriminoSampler(numSamples);

            sampler.Sample(new ProbabilisticResult <Piece>(new Piece(Tetrimino.T), 0.3));
            sampler.Sample(new ProbabilisticResult <Piece>(new Piece(Tetrimino.J), 0.5));

            var complete = sampler.IsComplete;

            Assert.False(complete);
        }
예제 #2
0
        public void SampleFails(int numSamples)
        {
            var sampler = new CurrentTetriminoSampler(numSamples);

            for (int i = 0; i < numSamples; i++)
            {
                var sample = new ProbabilisticResult <Piece>(new Piece((Tetrimino)i), 0.5);
                sampler.Sample(sample);
            }

            Assert.Throws <ArgumentException>(() =>
            {
                sampler.Sample(new ProbabilisticResult <Piece>(new Piece(Tetrimino.T), 0.5));
            });
        }
예제 #3
0
        public void CaseEarlyMajority()
        {
            int numSamples = 3;
            var sampler    = new CurrentTetriminoSampler(numSamples);

            sampler.Sample(new ProbabilisticResult <Piece>(new Piece(Tetrimino.I), 0.3));
            Assert.False(sampler.IsComplete);

            sampler.Sample(new ProbabilisticResult <Piece>(new Piece(Tetrimino.I), 0.8));
            Assert.True(sampler.IsComplete);

            var result = sampler.Result;

            Assert.AreEqual(Tetrimino.I, result.Tetrimino);
        }
예제 #4
0
        public void CaseDifferentY()
        {
            int numSamples = 3;
            var sampler    = new CurrentTetriminoSampler(numSamples);

            sampler.Sample(new ProbabilisticResult <Piece>(new Piece(Tetrimino.I).Fall(5), 0.6));
            Assert.False(sampler.IsComplete);

            sampler.Sample(new ProbabilisticResult <Piece>(new Piece(Tetrimino.I).Fall(7), 0.5));
            Assert.True(sampler.IsComplete);

            var result = sampler.Result;

            Assert.AreEqual(Tetrimino.I, result.Tetrimino);
            Assert.AreEqual(7, result.FallHeight);
        }
예제 #5
0
        public void CaseMixed()
        {
            int numSamples = 3;
            var sampler    = new CurrentTetriminoSampler(numSamples);

            sampler.Sample(new ProbabilisticResult <Piece>(new Piece(Tetrimino.T), 0.4));
            Assert.False(sampler.IsComplete);

            sampler.Sample(new ProbabilisticResult <Piece>(new Piece(Tetrimino.J), 0.5));
            Assert.False(sampler.IsComplete);

            sampler.Sample(new ProbabilisticResult <Piece>(new Piece(Tetrimino.L), 0.3));
            Assert.True(sampler.IsComplete);

            var result = sampler.Result;

            Assert.AreEqual(Tetrimino.J, result.Tetrimino);
        }
예제 #6
0
        public void Sample(int numSamples)
        {
            var sampler = new CurrentTetriminoSampler(numSamples);

            for (int i = 0; i < numSamples; i++)
            {
                var sample = new ProbabilisticResult <Piece>(new Piece((Tetrimino)i), 0.5);
                sampler.Sample(sample);
            }
        }