Example #1
0
        private void RandomIAPlayerTurn()
        {
            Random rnd = new Random();
            Choice = new Choice();

            for (int i = 0; i < 5; i++)
            {
                Choice.ChoiceBoards[i] = new ChoiceBoard();
                Choice.ChoiceBoards[i].IdBoard = i;

                //--- En commentaire pour le test avec des valeurs par défaut
                Choice.ChoiceBoards[i].IdPlayerCard = ListIndexPickedCard[Game.rnd.Next(0, ListIndexPickedCard.Count)];
                ListIndexPickedCard.Remove(Choice.ChoiceBoards[i].IdPlayerCard);
                //---
            }

            //--- Test, valeur par défaut
            //oppositePlayer.Choice.ChoiceBoards[0].IdPlayerCard = 13;
            //oppositePlayer.Choice.ChoiceBoards[1].IdPlayerCard = 4;
            //oppositePlayer.Choice.ChoiceBoards[2].IdPlayerCard = 10;
            //oppositePlayer.Choice.ChoiceBoards[3].IdPlayerCard = 2;
            //oppositePlayer.Choice.ChoiceBoards[4].IdPlayerCard = 1;

            //oppositePlayer.ListIndexPickedCard.Remove(12);
            //oppositePlayer.ListIndexPickedCard.Remove(4);
            //oppositePlayer.ListIndexPickedCard.Remove(10);
            //oppositePlayer.ListIndexPickedCard.Remove(2);
            //oppositePlayer.ListIndexPickedCard.Remove(1);
            //---
        }
Example #2
0
        private void PlayerTurnRecursively(Choice choice, int numBoard)
        {
            if (numBoard >= Game.Boards.Length)
            {
                CalcScore(choice);

                if (Choice == null || choice.Score >= Choice.Score)
                    Choice = choice;

                return;
            }

            for (int i = 0; i < choice.IdPlayerCards.Count; i++)
            {
                Choice newChoice = choice.Clone();

                newChoice.SetPlayerChoice(Game.Boards[numBoard], i);

                PlayerTurnRecursively(newChoice, numBoard + 1);
            }
        }
Example #3
0
        private void CalcScore(Choice choiceFriendPlayer)
        {
            for (int i = 0; i < 5; i++)
            {
                Card friendPlayerCard = ListCard[choiceFriendPlayer.ChoiceBoards[i].IdPlayerCard];
                Card oppositePlayerCard = OtherPlayer.ListCard[OtherPlayer.Choice.ChoiceBoards[i].IdPlayerCard];
                int value = 0;
                int f = friendPlayerCard.Value;
                int o = oppositePlayerCard.Value;

                if (friendPlayerCard.CardType == CardType.Value)
                {
                    if (oppositePlayerCard.CardType == CardType.Value)
                    {
                        value = f - o;
                    }
                    else if (oppositePlayerCard.CardType == CardType.PlusValue)
                    {
                        value = -f - o;
                    }
                    else if (oppositePlayerCard.CardType == CardType.MinusValue)
                    {
                        value = 1;
                    }
                }
                else if (friendPlayerCard.CardType == CardType.PlusValue)
                {
                    if (oppositePlayerCard.CardType == CardType.Value)
                    {
                        value = f + o;
                    }
                    else if (oppositePlayerCard.CardType == CardType.PlusValue)
                    {
                        value = f - o;
                    }
                    else if (oppositePlayerCard.CardType == CardType.MinusValue)
                    {
                        value = f;
                    }
                }
                else if (friendPlayerCard.CardType == CardType.MinusValue)
                {
                    if (oppositePlayerCard.CardType == CardType.Value)
                    {
                        value = -1;
                    }
                    else if (oppositePlayerCard.CardType == CardType.PlusValue)
                    {
                        value = -o;
                    }
                    else if (oppositePlayerCard.CardType == CardType.MinusValue)
                    {
                        value = 0;
                    }
                }

                choiceFriendPlayer.ChoiceBoards[i].Score = value;

                choiceFriendPlayer.Score += Game.Boards[i].PawnsFriendPlayer + (choiceFriendPlayer.ChoiceBoards[i].Score + Math.Sign(choiceFriendPlayer.ChoiceBoards[i].Score)) * Game.Boards[i].Scores[(Game.turn - 1) / 3] * 4;
            }
        }
Example #4
0
        private void IAPlayerTurn()
        {
            Choice = null;

            Choice choice = new Choice();

            for (int i = 0; i < ListIndexPickedCard.Count; i++)
            {
                choice.IdPlayerCards.Add(ListIndexPickedCard[i]);
            }

            PlayerTurnRecursively(choice, 0);

            //--- Supprime les cartes consommées
            for (int i = 0; i < 5; i++)
            {
                if (Choice.ChoiceBoards[i].IdPlayerCard > 5)
                {
                    ListIndexPickedCard.Remove(Choice.ChoiceBoards[i].IdPlayerCard);
                    ListIndexAvailableCard.Remove(Choice.ChoiceBoards[i].IdPlayerCard);
                }
            }
            //---
        }
Example #5
0
        public Choice Clone()
        {
            Choice clone = new Choice();

            for (int i = 0; i < this.ChoiceBoards.Length; i++)
            {
                if (this.ChoiceBoards[i] != null)
                {
                    clone.ChoiceBoards[i] = new ChoiceBoard();
                    clone.ChoiceBoards[i].IdBoard = this.ChoiceBoards[i].IdBoard;
                    clone.ChoiceBoards[i].IdPlayerCard = this.ChoiceBoards[i].IdPlayerCard;
                }
            }

            clone.IdPlayerCards.AddRange(this.IdPlayerCards.ToArray());

            return clone;
        }