Пример #1
0
        public Variant.Type SelectBestAvailableChoice()
        {
            int highestValue = 0;

            Variant.Type highVariant        = 0;
            int[]        getValueByVariants = new int[variant.Length()]; // NullReferenceException here when resuming game

            foreach (Variant.Type vari in variant.GetList())
            {
                int i = variant.GetValue(vari);
                getValueByVariants[i] = rules.GetValueByVariant(vari);
                if (vari != variant.Chance() && !GetPickedChoice(vari) && getValueByVariants[i] >= highestValue)
                {
                    highestValue = getValueByVariants[i];
                    highVariant  = vari;
                }
            }

            getValueByVariants[12] = rules.GetValueByVariant(variant.Chance());
            if (!GetPickedChoice(variant.Chance()) && getValueByVariants[12] > highestValue && highestValue <10 && highVariant> variant.Threes() && highVariant < variant.Yahtzee())
            {
                highVariant = variant.Chance();
            }
            return(highVariant);
        }
Пример #2
0
        private void PlayRound(Player player)
        {
            Ai ai = player as Ai;

            Variant.Type choiceToPick = variant.Chance();

            renderer.RenderRound(player.Name);

            for (int rollNumber = 1; rollNumber <= 3; rollNumber++)
            {
                RolledDice(rollNumber, player, ai);
            }
            if (player.IsAI)
            {
                choiceToPick = ai.SelectBestAvailableChoice();
            }
            else
            {
                choiceToPick = renderer.RenderChoices(player.GetTakenChoices(variant));
            }

            AddingScoreToList(player, choiceToPick);
        }