コード例 #1
0
        //and his methods
        //The most stupid bot ever.
        //Ходить с минимальной некозырной карты. Если таковой не имеется,
        //ходить с минимальной козырной. Если несколько минимальных карт
        //И у атакуемого игрока количество карт, не меньше, чем количество
        //карт, которые подходят под вышеописанные условия.

        //Если есть возможность - у защищающегося есть карты на руках И
        //(есть подходящая некозырная карта ИЛИ на руках остались только
        //козыри и минимальный из них можно подкинуть без нарушения правил)

        //Выбирается минимальная по номиналу из некозырных, которой можно
        //побить карту на столе (если такой карты нет, то искать минимальную
        //карту из козырных). Если нет возможности покрыть карту, то брать. #

        public AttackResponse FirstMove(MoveInfo moveInfo)
        {
            //throw new NotImplementedException();
            var cardToMove = new Card(Program.trumpCard.suit, Nominal.Ace);

            foreach (var value in moveInfo.PlayerHand)
            {
                if (value.suit != Program.trumpCard.suit && value.nominal <= cardToMove.nominal)
                {
                    cardToMove = value;
                }
            }
            if (cardToMove.suit == Program.trumpCard.suit)
            {
                foreach (var value in moveInfo.PlayerHand)
                {
                    if (value.nominal < cardToMove.nominal)
                    {
                        cardToMove = value;
                    }
                }
            }
            var response = new AttackResponse();

            response.OffCards = new List <Card>();
            response.OffCards.Add(cardToMove);
            return(response);
        }
コード例 #2
0
 static public void TryToAttack(AttackResponse attack, int whoAttack)
 {
     if (attack.OffCards.Count <= Program.players[whoAttack].hand.Count)
     {
         foreach (var e in attack.OffCards)
         {
             if (!Program.players[whoAttack].hand.Contains(e))
             {
                 throw new Exception();
             }
             else
             {
                 Program.players[whoAttack].hand.Remove(e);
             }
         }
     }
     else
     {
         throw new Exception(); // will be changed
     }
 }
コード例 #3
0
        public AttackResponse AdditionalMove(MoveInfo moveInfo)//Table table, int enemyCardCount, List<Card> myHand)
        {
            //throw new NotImplementedException();
            var response = new AttackResponse();

            response.OffCards = new List <Card>();
            var enemyCardCount = moveInfo.CountOfDefenseCards;

            if (moveInfo.CurrentTable.TablePosition.Count == 0)
            {
                throw new Exception("somthing went wrong in AdditionalMove :C");
            }
            foreach (var value in moveInfo.CurrentTable.TablePosition)
            {
                if (moveInfo.PlayerHand.Contains(value.DefCard) && value.DefCard.nominal != Program.trumpCard.nominal)
                {
                    foreach (var value2 in moveInfo.PlayerHand)
                    {
                        if (value2.nominal == value.DefCard.nominal && enemyCardCount != 0)
                        {
                            response.OffCards.Add(value2);
                            enemyCardCount--;
                        }
                    }
                }
                if (moveInfo.PlayerHand.Contains(value.OffCard) && value.OffCard.nominal != Program.trumpCard.nominal)
                {
                    foreach (var value2 in moveInfo.PlayerHand)
                    {
                        if (value2.nominal == value.OffCard.nominal && enemyCardCount != 0)
                        {
                            response.OffCards.Add(value2);
                            enemyCardCount--;
                        }
                    }
                }
            }
            return(response);
        }
コード例 #4
0
        static public Dictionary <string, Card> defaultPack = FormDict(); //словарь со всеми картами.
        static void Main(string[] args)
        {
            Console.WriteLine("Let's play!");
            pack      = Arbiter.FormInitialPack();
            trumpCard = pack.First();
            players   = new Player[countOfPlayer];
            for (int i = 0; i < countOfPlayer; i++)
            {
                players[i] = new Player();
                Arbiter.GiveCardsToPlayer(players[i], pack);
            }
            foreach (Nominal nominal in (Nominal[])Enum.GetValues(typeof(Nominal)))
            {
                Card card = new Card(trumpCard.suit, nominal);
                for (int i = 0; i < countOfPlayer; i++)
                {
                    if (players[i].hand.Contains(card))
                    {
                        turn = (i + 1) % countOfPlayer;
                        break;
                    }
                }
            }
            bool t = false;

            while (true)
            {
                if (t)
                {
                    break;
                }
                AttackResponse firstAttack = players[(turn - 1 + countOfPlayer) % countOfPlayer].FirstMove(
                    new MoveInfo()
                {
                    CurrentTable = table, PlayerHand = players[(turn - 1 + countOfPlayer) % countOfPlayer].hand, Suit = trumpCard.suit
                });
                Arbiter.TryToAttack(firstAttack, (turn - 1 + countOfPlayer) % countOfPlayer);
                while (true)//Пока что понятия не имею, когда это закончить. нужна помощь
                {
                    DefendInfo defend = players[turn].Defend(
                        new MoveInfo()
                    {
                        CurrentTable = table, PlayerHand = players[(turn - 1 + countOfPlayer) % countOfPlayer].hand, Suit = trumpCard.suit
                    });
                    if (defend.Move == WhatMove.Translate)
                    {
                        turn += 1;
                        continue;
                    }
                    if (defend.Move == WhatMove.Take)
                    {
                        turn = (turn + 2) % countOfPlayer;
                        break;
                    }
                    AttackResponse addAttack = players[(turn + 1) % countOfPlayer].AdditionalMove(
                        new MoveInfo()
                    {
                        CurrentTable = table, PlayerHand = players[(turn - 1 + countOfPlayer) % countOfPlayer].hand, Suit = trumpCard.suit
                    });
                    Arbiter.TryToAttack(addAttack, (turn + 1) % countOfPlayer);
                    addAttack = players[(turn - 1 + countOfPlayer) % countOfPlayer].AdditionalMove(
                        new MoveInfo()
                    {
                        CurrentTable = table, PlayerHand = players[(turn - 1 + countOfPlayer) % countOfPlayer].hand, Suit = trumpCard.suit
                    });
                    Arbiter.TryToAttack(addAttack, (turn - 1 + countOfPlayer) % countOfPlayer);
                }
            }
        }