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); }
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)); }); }
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); }
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); }
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); }
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); } }