Example #1
0
        public Card getNextCard(PlayerState p, List <Card> hand)
        {
            Card cur = ult.playPrimary(p, hand);

            if (cur != null)
            {
                return(cur);
            }

            if (((p.getBoard().getName().Equals("WB1")) ||
                 (p.getBoard().getName().Equals("WB1")) &&
                 (p.getBoard().getCurrentWonderLevel() == 2)))
            {
                cur = ult.buildWonder(p, hand);
                if (cur != null)
                {
                    return(cur);
                }
            }


            cur = ult.playSecondary(p, hand);
            if (cur != null)
            {
                return(cur);
            }

            cur = ult.buildWonder(p, hand);
            if (cur != null)
            {
                return(cur);
            }

            return(ult.playAnyCard(p, hand));
        }
        public Card getNextCard(PlayerState p, List <Card> hand)
        {
            Card cur = ult.playPrimary(p, hand);

            if (cur != null)
            {
                return(cur);
            }

            //attempts to play wonder to increase science
            if ((p.getBoard().getName().Equals("WB3")) &&
                (p.getBoard().getCurrentWonderLevel() < 2) &&
                (ResourceManager.GetInstance().ValidateWonder(p)))
            {
                for (int i = 0; i < hand.Count; i++)
                {
                    if (hand[i].getType() != 6)
                    {
                        p.setWonderCards(hand[i]);
                        p.getBoard().incrementWonderLevel(p);
                        return(hand[i]);
                    }
                }
            }

            if ((p.getBoard().getName().Equals("WB4")) &&
                (p.getBoard().getCurrentWonderLevel() < 3) &&
                (ResourceManager.GetInstance().ValidateWonder(p)))
            {
                for (int i = 0; i < hand.Count; i++)
                {
                    if (hand[i].getType() != 6)
                    {
                        p.setWonderCards(hand[i]);
                        p.getBoard().incrementWonderLevel(p);
                        return(hand[i]);
                    }
                }
            }

            cur = ult.playSecondary(p, hand);
            if (cur != null)
            {
                return(cur);
            }

            cur = ult.buildWonder(p, hand);
            if (cur != null)
            {
                return(cur);
            }

            return(ult.playAnyCard(p, hand));
        }
        public Card getNextCard(PlayerState p, List <Card> hand)
        {
            PlayerState left  = ResourceManager.GetInstance().getGameState().getLeftPlayer(p);
            PlayerState right = ResourceManager.GetInstance().getGameState().getRightPlayer(p);
            int         age   = ResourceManager.GetInstance().getGameState().getAge();

            Card cur;

            //Checks to see if AI has enough MilitaryPower to win the
            //the battles at the end of the Age
            if ((left.getMilitaryPower() >= p.getMilitaryPower() - age) ||
                (right.getMilitaryPower() >= p.getMilitaryPower() - age))
            {
                cur = ult.playPrimary(p, hand);
                if (cur != null)
                {
                    return(cur);
                }
            }

            //attempts to play wonder to increase military
            if ((p.getBoard().getName().Equals("WB7")) &&
                (p.getBoard().getCurrentWonderLevel() < 2) &&
                (ResourceManager.GetInstance().ValidateWonder(p)))
            {
                for (int i = 0; i < hand.Count; i++)
                {
                    if (hand[i].getType() != 6)
                    {
                        p.setWonderCards(hand[i]);
                        p.getBoard().incrementWonderLevel(p);
                        return(hand[i]);
                    }
                }
            }

            if ((p.getBoard().getName().Equals("WB8")) &&
                (p.getBoard().getCurrentWonderLevel() < 2) &&
                (ResourceManager.GetInstance().ValidateWonder(p)))
            {
                for (int i = 0; i < hand.Count; i++)
                {
                    if (hand[i].getType() != 6)
                    {
                        p.setWonderCards(hand[i]);
                        p.getBoard().incrementWonderLevel(p);
                        return(hand[i]);
                    }
                }
            }

            cur = ult.playSecondary(p, hand);
            if (cur != null)
            {
                return(cur);
            }

            cur = ult.buildWonder(p, hand);
            if (cur != null)
            {
                return(cur);
            }

            return(ult.playAnyCard(p, hand));
        }
Example #4
0
        public Card getNextCard(PlayerState p, List <Card> hand)
        {
            List <CivilianCard> civCards = new List <CivilianCard>();

            for (int i = 0; i < hand.Count; i++)
            {
                if (hand[i].getType() == 3)
                {
                    System.Console.WriteLine("CivilianStrategy():: getNextCard({0})", hand[i]);
                    civCards.Add((CivilianCard)hand[i]);
                }
            }

            // && (ResourceManager.GetInstance().ValidateCard(p, hand[i]))
            int trade;

            while (civCards.Count != 0)
            {
                CivilianCard bestCard = civCards[0];

                for (int i = 1; i < civCards.Count; i++)
                {
                    if (bestCard.getVictoryPoints() < civCards[i].getVictoryPoints())
                    {
                        bestCard = civCards[i];
                    }
                }
                if (ResourceManager.GetInstance().ValidateCard(p, bestCard))
                {
                    p.addPlayedCards(bestCard);
                    return(bestCard);
                }

                trade = ResourceManager.GetInstance().validateTrade(p, bestCard, 0);

                if ((trade > 0) && (p.getCoins() >= trade))
                {
                    //.WriteLine(p.getName() + " trading for " + trade);
                    p.updateCoins(-trade);
                    ResourceManager.GetInstance().getGameState().getRightPlayer(p).updateCoins(trade);
                    p.addPlayedCards(bestCard);
                    return(bestCard);
                }

                trade = ResourceManager.GetInstance().validateTrade(p, bestCard, 1);

                if ((trade > 0) && (p.getCoins() >= trade))
                {
                    //Console.WriteLine(p.getName() + " trading for " + trade);
                    p.updateCoins(-trade);
                    p.addPlayedCards(bestCard);
                    ResourceManager.GetInstance().getGameState().getLeftPlayer(p).updateCoins(trade);
                    return(bestCard);
                }
                civCards.Remove(bestCard);
            }

            Card cur = ult.playSecondary(p, hand);

            if (cur != null)
            {
                return(cur);
            }

            cur = ult.buildWonder(p, hand);
            if (cur != null)
            {
                return(cur);
            }

            return(ult.playAnyCard(p, hand));
        }