Beispiel #1
0
 public PerfectInformationGame(PlayerNode p0, PlayerNode p1, PlayerNode p2, PlayerNode p3, int trumpSuit, List <Trick> pastMoves, int myTeamPoints, int otherTeamPoints, bool HYBRID_FLAG = false, int hybridTrickChange = 5)
 {
     players = new PlayerNode[4] {
         p0, p1, p2, p3
     };
     trump  = trumpSuit;
     tricks = new List <Trick>(10);
     foreach (Trick t in pastMoves)
     {
         Trick copyTrick = new Trick(trumpSuit);
         foreach (Move m in t.GetMoves())
         {
             copyTrick.ApplyMove(m);
             foreach (PlayerNode p in players)
             {
                 p.ApplyMove(m);
             }
         }
         tricks.Add(copyTrick);
     }
     firstTeamPoints        = myTeamPoints;
     secondTeamPoints       = otherTeamPoints;
     predictableTrickWinner = -1;
     predictableTrickCut    = false;
     hybridFlag             = HYBRID_FLAG;
     this.hybridTrickChange = hybridTrickChange;
 }
Beispiel #2
0
        internal void ApplyMove(Move move)
        {
            Trick currentTrick = tricks[tricks.Count - 1];

            if (currentTrick.IsFull())
            {
                tricks.Add(new Trick(trump));
                currentTrick = tricks[tricks.Count - 1];
            }
            currentTrick.ApplyMove(move);

            if (currentTrick.IsFull())
            {
                predictableTrickWinner = -1;
                predictableTrickCut    = false;
                int[] winnerPoints = currentTrick.GetTrickWinnerAndPoints();
                if (winnerPoints[0] == players[0].Id || winnerPoints[0] == (players[0].Id + 2) % 4)
                {
                    firstTeamPoints += winnerPoints[1];
                }
                else
                {
                    secondTeamPoints += winnerPoints[1];
                }
            }

            foreach (var p in players)
            {
                //TODO review if is this the correct method
                p.ApplyMove(move);
            }
        }
Beispiel #3
0
        public void PlayCard(int playerId, int card)
        {
            if (tricks.Count - 1 < 0)
            {
                Console.WriteLine("SuecaGame.PlayerCard >> Negative index");
                //System.Environment.Exit(1);
            }

            Trick currentTrick = tricks[tricks.Count - 1];

            if (currentTrick.IsFull())
            {
                tricks.Add(new Trick(trump));
                currentTrick = tricks[tricks.Count - 1];
            }
            currentTrick.ApplyMove(new Move(playerId, card));
        }
        public void AddPlay(int playerID, int card)
        {
            Trick currentTrick = tricks[tricks.Count - 1];

            if (currentTrick.IsFull())
            {
                int[] winnerPoints = currentTrick.GetTrickWinnerAndPoints();
                if (winnerPoints[0] == id || winnerPoints[0] == (id + 2) % 4)
                {
                    MyTeamPoints += winnerPoints[1];
                }
                else
                {
                    //TODO checks valence of points!!!
                    OtherTeamPoints += winnerPoints[1];
                }
                tricks.Add(new Trick(Trump));
                currentTrick = tricks[tricks.Count - 1];
            }

            //check if player has the leadSuit
            int leadSuit  = currentTrick.LeadSuit;
            int cardSuit  = Card.GetSuit(card);
            int cardValue = Card.GetValue(card);

            if (playerID != id && cardSuit == leadSuit && !suitHasPlayer[leadSuit].Contains(playerID))
            {
                Console.WriteLine("AddPlay: The player has renounced!");
            }

            currentTrick.ApplyMove(new Move(playerID, card));

            if (playerID != id && cardSuit != leadSuit && leadSuit != (int)Suit.None)
            {
                if (suitHasPlayer[leadSuit].Contains(playerID))
                {
                    suitHasPlayer[leadSuit].Remove(playerID);
                }
            }

            if (cardSuit == Trump)
            {
                remainingTrumps--;
            }
            if (playerID == id)
            {
                if (hand.Remove(card) == false)
                {
                    //Console.WriteLine("INFOSET Trying to remove an nonexisting card!!!");
                }
            }
            else
            {
                if (TrumpCard == card)
                {
                    trumpCardWasPlayed = true;
                }
                else
                {
                    if (unknownOwnerCards.RemoveCard(card) == false)
                    {
                        Console.WriteLine("FILIPA");
                    }
                }
                if (cardValue > 0)
                {
                    othersPointCards[cardSuit].Remove(Card.GetRank(card));
                }
            }
        }