public void ConstructorFails(int numSamples)
        {
            Assert.Throws <ArgumentException>(() =>
            {
                var sampler = new MultiplayerPenaltyLinesHolePositionSampler(numSamples);

                Assert.NotNull(sampler);
            });
        }
        public void Sample(int numSamples)
        {
            var sampler = new MultiplayerPenaltyLinesHolePositionSampler(numSamples);

            for (int i = 0; i < numSamples; i++)
            {
                var sample = new ProbabilisticResult <int>(i, 0.5);
                sampler.Sample(sample);
            }
        }
        public void Incomplete()
        {
            int numSamples = 3;
            var sampler    = new MultiplayerPenaltyLinesHolePositionSampler(numSamples);

            sampler.Sample(new ProbabilisticResult <int>(7, 0.3));
            sampler.Sample(new ProbabilisticResult <int>(2, 0.5));

            var complete = sampler.IsComplete;

            Assert.False(complete);
        }
        public void CompleteByMajority()
        {
            int numSamples = 3;
            var sampler    = new MultiplayerPenaltyLinesHolePositionSampler(numSamples);

            sampler.Sample(new ProbabilisticResult <int>(6, 0.3));
            sampler.Sample(new ProbabilisticResult <int>(6, 0.5));

            var complete = sampler.IsComplete;

            Assert.True(complete);
        }
        public void SampleFails(int numSamples)
        {
            var sampler = new MultiplayerPenaltyLinesHolePositionSampler(numSamples);

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

            Assert.Throws <ArgumentException>(() =>
            {
                sampler.Sample(new ProbabilisticResult <int>(9, 0.5));
            });
        }
        public void CaseEarlyMajority()
        {
            int numSamples = 3;
            var sampler    = new MultiplayerPenaltyLinesHolePositionSampler(numSamples);

            sampler.Sample(new ProbabilisticResult <int>(2, 0.3));
            Assert.False(sampler.IsComplete);

            sampler.Sample(new ProbabilisticResult <int>(2, 0.8));
            Assert.True(sampler.IsComplete);

            var result = sampler.Result;

            Assert.AreEqual(2, result);
        }
        public void CaseMixed()
        {
            int numSamples = 3;
            var sampler    = new MultiplayerPenaltyLinesHolePositionSampler(numSamples);

            sampler.Sample(new ProbabilisticResult <int>(6, 0.4));
            Assert.False(sampler.IsComplete);

            sampler.Sample(new ProbabilisticResult <int>(5, 0.5));
            Assert.False(sampler.IsComplete);

            sampler.Sample(new ProbabilisticResult <int>(4, 0.3));
            Assert.True(sampler.IsComplete);

            var result = sampler.Result;

            Assert.AreEqual(5, result);
        }
Example #8
0
        private void Init()
        {
            ResetVisualization();

            // init game state and agent state
            if (IsMultiplayer)
            {
                MultiplayerHoleSampler = new MultiplayerPenaltyLinesHolePositionSampler(NumSamples);

                // TODO: is it correct that the game in multiplayer mode starts always in level 0?
                GameState = new GameState {
                    StartLevel = 0, HeartMode = false
                };
            }
            else
            {
                GameState = new GameState {
                    StartLevel = StartLevel, HeartMode = IsHeartMode
                };
            }

            SetState(new ReadyState(this));
        }
        public void Constructor(int numSamples)
        {
            var sampler = new MultiplayerPenaltyLinesHolePositionSampler(numSamples);

            Assert.NotNull(sampler);
        }