示例#1
0
        public override int PlayGame(PerfectInformationGame pig, int alpha, int beta, int depthLimit, int card)
        {
            int        v = Int16.MinValue;
            List <int> cards;

            if (Sueca.UTILITY_FUNC == 2 && pig.IsAnyTeamWinning())
            {
                return(pig.EvalGame2());
            }
            if (pig.reachedDepthLimit(depthLimit) || pig.IsEndGame())
            {
                return(pig.EvalGame1());
            }

            if (card == -1)
            {
                cards = Sueca.PossibleMoves(Hand, pig.GetLeadSuit());
                pig.orderPossibleMoves(cards, Id);
            }
            else
            {
                cards = new List <int>();
                cards.Add(card);
            }

            foreach (int c in cards)
            {
                Move move = new Move(Id, c);
                pig.ApplyMove(move);
                int moveValue = pig.GetNextPlayer().PlayGame(pig, alpha, beta, depthLimit);

                if (moveValue > v)
                {
                    v = moveValue;
                }

                pig.UndoMove(move);

                if (v >= beta)
                {
                    return(v);
                }

                if (v > alpha)
                {
                    alpha = v;
                }
            }

            return(v);
        }
示例#2
0
        override public int Play()
        {
            if (currentPlay == 0)
            {
                leadSuit = (int)Suit.None;
            }

            List <int> possibleMoves = Sueca.PossibleMoves(hand, leadSuit);
            int        randomIndex   = randomNumber.Next(0, possibleMoves.Count);
            int        chosenCard    = possibleMoves[randomIndex];

            hand.Remove(chosenCard);

            return(chosenCard);
        }
        public List <int> GetPossibleMoves()
        {
            Trick currentTrick = tricks[tricks.Count - 1];

            return(Sueca.PossibleMoves(hand, currentTrick.LeadSuit));
        }