Ejemplo n.º 1
0
 public bool hasCard(Card compare)
 {
     foreach (Card card in hand)
     {
         if (card.Equals(compare))
             return true;
     }
     return false;
 }
Ejemplo n.º 2
0
 public GameState(Player[] players, int turnIndex, Card[] trick, Suit leadSuit, int cardsPlayedInTrick)
 {
     this.players = new Player[4];
     for (int i = 0; i < 4; i++)
     {
         this.players[i] = players[i].clone();
     }
     this.turnIndex = turnIndex;
     this.trick = trick;
     this.leadSuit = leadSuit;
     this.cardsPlayedInTrick = cardsPlayedInTrick;
 }
Ejemplo n.º 3
0
        private static int getPlayouts(GameState state, Card card, int pIndex)
        {
            int wins = 0;

            if (state.gameOver()) return 0;
            GameState playState = state.getNextState(true, card, true);
            for (int i = 0; i < NUM_PLAYOUTS; i++)
            {
                if (playout(playState, pIndex))
                    wins++;
            }
            return wins;
        }
Ejemplo n.º 4
0
        public Deck()
        {
            cards = new List<Card>();

            Suit[] suits = { Suit.Clubs, Suit.Hearts, Suit.Spades, Suit.Diamonds };
            for (int i = 2; i <= 14; i++)
            {
                foreach (Suit suit in suits)
                {
                    Card card = new Card(suit, i);
                    cards.Add(card);
                }
            }
            shuffle();
        }
Ejemplo n.º 5
0
 public GameState getNextState(bool preserve, Card played, bool playRandom)
 {
     GameState newState = new GameState(players, turnIndex, trick, leadSuit, cardsPlayedInTrick);
     if (preserve)
     {
         if (played == null)
         {
             newState.getNextState(playRandom);
         }
         else
         {
             newState.getNextState(played);
         }
     }
     return newState;
 }
Ejemplo n.º 6
0
 public void removeCard(Card card)
 {
     cards.Remove(card);
 }
Ejemplo n.º 7
0
 public void seeCard(Card card)
 {
     unknownCards.removeCard(card);
 }
Ejemplo n.º 8
0
 public void removeCard(Card card)
 {
     hand.Remove(card);
 }
Ejemplo n.º 9
0
 public void giveCard(Card card)
 {
     hand.Add(card);
     seeCard(card);
 }
Ejemplo n.º 10
0
        public void getNextState(Card played)
        {
            trick[turnIndex] = played;
            players[turnIndex].removeCard(played);
            Console.WriteLine(played);

            if (leadSuit == Suit.None)
            {
                leadSuit = played.suit;
            }
            cardsPlayedInTrick++;

            if (cardsPlayedInTrick == 4)
            {
                scoreTrick(leadSuit);
            }
            else
            {
                turnIndex = (turnIndex + 1) % 4;
            }
        }
Ejemplo n.º 11
0
 private int getFirstPlayer()
 {
     Card startCard = new Card(Suit.Clubs, 2);
     for (int i = 0; i < 4; i++)
     {
         if (players[i].hasCard(startCard))
         {
             return i;
         }
     }
     return -1;
 }