Exemplo n.º 1
0
 public void Remove(KeyCombinationData data)
 {
     if (CombinationList.Contains(data) == true)
     {
         CombinationList.Remove(data);
     }
 }
Exemplo n.º 2
0
 public void RemoveAt(int Index)
 {
     if (CombinationList.Count <= Index || Index < 0)
     {
         return;
     }
     CombinationList.RemoveAt(Index);
 }
Exemplo n.º 3
0
        public Player(PlayerType playerType, string name, ActionReader actionReader)
        {
            PlayerType         = playerType;
            Name               = name;
            Random             = new Random();
            RolledDice         = new int[6];
            FixedDice          = Enumerable.Repeat(false, 6).ToArray();
            TotalNumberOfRolls = 0;
            Board              = new Board();
            CombinationList    = new CombinationList();
            ActionReader       = actionReader;
            CombinationToPlay  = CombinationType.Unknown;
            FirstAction        = false;
            Round              = Round.One;

            // PatternProbabilities - Load list of all possible pattern probabilities
            PatternProbabilities = GameUtility.CreatePatternProbabilitiesDictionary();
        }
Exemplo n.º 4
0
        public void GenericPatterns_CheckIfWeHaveAllNeededPatterns()
        {
            var dice = new int[6] {
                0, 0, 0, 0, 0, 0
            };
            var patterns = GameUtility.GetPatterns();

            // Add empty pattern for simplicity of this test
            patterns.Add(new char[] { });
            var patternFrequencies = patterns.ToDictionary(x => x, x => 0, new ArrayEqualityComparerChar());
            var combinationList    = new CombinationList();
            var isPatternMissing   = false;

            var count = 0;

            foreach (var rollWithCombinations in combinationList.ReadFullRollListWithAllMatchingCombinations())
            {
                dice = rollWithCombinations.Key;
                count++;
                foreach (var com in combinationList.Combinations)
                {
                    var missingDice = com.MissingDiceToCompleteCombination(dice);

                    var pattern = GameUtility.CreateGenericPatternFromDice(missingDice);

                    if (!patternFrequencies.ContainsKey(pattern))
                    {
                        isPatternMissing = true;
                    }
                    else
                    {
                        patternFrequencies[pattern]++;
                    }
                }
            }

            Assert.False(isPatternMissing);
            Assert.Equal(Math.Pow(6, 6) * combinationList.Combinations.Length, patternFrequencies.Sum(x => x.Value));
            Assert.Equal(Math.Pow(6, 6), count);
            foreach (var pat in patternFrequencies)
            {
                Assert.True(pat.Value > 0);
            }
        }
Exemplo n.º 5
0
        public void EvaluateDice()
        {
            // Find possible combinations. Don't include combinations which were already completed
            // and also don't include combinations which cannot be played (in Round Two and Three)
            var matchingCombinations = CombinationList.LookupMatchingCombinations(RolledDice);
            var tempCombinations     = new List <Combination>();

            foreach (var combination in matchingCombinations)
            {
                if ((Round == Round.Two || Round == Round.Three) && combination.CombinationType != CombinationToPlay)
                {
                    continue;
                }

                if (!Board.CurrentBoard[combination.CombinationType].Completed)
                {
                    tempCombinations.Add(combination);
                }
            }
            CurrentPossibleCombinations = tempCombinations.ToArray();
        }
Exemplo n.º 6
0
        public void GenericPatterns_CheckIfWeHaveAllPatternProbabilities()
        {
            var player = new Player(PlayerType.Human, "test_player");
            var patternProbabilities = player.PatternProbabilities;
            var combinationList      = new CombinationList();
            var isPatternMissing     = false;

            // Use the list of all possible rolls to test if we have all pattern probabilities needed
            foreach (var rollWithCombinations in combinationList.ReadFullRollListWithAllMatchingCombinations())
            {
                var rolledDice = rollWithCombinations.Key;

                foreach (var c in combinationList.Combinations)
                {
                    var precomputedProbabilitiesCount = patternProbabilities.First().Value.Length;
                    c.SetProbabilitiesAndEVToCompleteCombinationWithinAllAvailableRolls(precomputedProbabilitiesCount, rolledDice, patternProbabilities);

                    if (c.ProbabilitiesToCompleteCombinationWithinAllAvailableRolls == null || c.ProbabilitiesToCompleteCombinationWithinAllAvailableRolls.Length != precomputedProbabilitiesCount)
                    {
                        isPatternMissing = true;
                        break;
                    }

                    if (c.ExpectedValuesForCombinationWithinAllAvailableRolls == null || c.ExpectedValuesForCombinationWithinAllAvailableRolls.Length != precomputedProbabilitiesCount)
                    {
                        isPatternMissing = true;
                        break;
                    }
                }

                if (isPatternMissing)
                {
                    break;
                }
            }

            Assert.False(isPatternMissing);
        }
Exemplo n.º 7
0
 public void Add(KeyCombinationData data)
 {
     CombinationList.Add(data);
 }
Exemplo n.º 8
0
 public HuTuckerBuilder()
 {
     combinationList = new CombinationList();
 }