private PlayerAction EndGameTurn(PlayerTurnContext context, ICardTracker tracker, ICollection <Card> myHand)
        {
            this.root = new Node(null, null, context.IsFirstPlayerTurn);

            if (context.IsFirstPlayerTurn && this.root.Children.Count == 0)
            {
                tracker.SetFinalRoundHands(myHand);
                var myCards = myHand.ToList();

                EndgameAnalyzer.Compute(this.root, null, myCards, tracker.OpponentTookWith, context.SecondPlayerRoundPoints, context.FirstPlayerRoundPoints);
            }
            else if (this.root.Children.Count == 0)
            {
                tracker.SetFinalRoundHands(myHand);
                var myCards = myHand.ToList();

                while (tracker.OpponentTookWith.Count < 6)
                {
                    tracker.OpponentTookWith.Add(null);
                }

                EndgameAnalyzer.Compute(this.root, context.FirstPlayedCard, myCards, tracker.OpponentTookWith, context.FirstPlayerRoundPoints, context.SecondPlayerRoundPoints);
            }

            if (!context.IsFirstPlayerTurn)
            {
                this.root = this.root.Children.First(x => x.Card == context.FirstPlayedCard);
            }

            var card = this.root.Children.OrderByDescending(x => x.Wins / (decimal)x.Total).First().Card;

            return(PlayerAction.PlayCard(card));
        }
        private PlayerAction EndGameTurn(PlayerTurnContext context, ICardTracker tracker, ICollection<Card> myHand)
        {
            this.root = new Node(null, null, context.IsFirstPlayerTurn);

            if (context.IsFirstPlayerTurn && this.root.Children.Count == 0)
            {
                tracker.SetFinalRoundHands(myHand);
                var myCards = myHand.ToList();

                EndgameAnalyzer.Compute(this.root, null, myCards, tracker.OpponentTookWith, context.SecondPlayerRoundPoints, context.FirstPlayerRoundPoints);
            }
            else if (this.root.Children.Count == 0)
            {
                tracker.SetFinalRoundHands(myHand);
                var myCards = myHand.ToList();

                while (tracker.OpponentTookWith.Count < 6)
                {
                    tracker.OpponentTookWith.Add(null);
                }

                EndgameAnalyzer.Compute(this.root, context.FirstPlayedCard, myCards, tracker.OpponentTookWith, context.FirstPlayerRoundPoints, context.SecondPlayerRoundPoints);
            }

            if (!context.IsFirstPlayerTurn)
            {
                this.root = this.root.Children.First(x => x.Card == context.FirstPlayedCard);
            }

            var card = this.root.Children.OrderByDescending(x => x.Wins / (decimal)x.Total).First().Card;

            return PlayerAction.PlayCard(card);
        }
 public GameAction(Card opponent, Card player, PlayerTurnContext context, ICardTracker cardTracker)
 {
     this.OpponetCard = opponent;
     this.PlayerCard = player;
     this.PlayerTakes = this.CheckIfPlayerTakes(opponent, player, context);
     this.HandValue = opponent.GetValue() + player.GetValue();
     this.CardMaxWorth = this.CardMaxWorthCalculator(player, cardTracker);
     this.OpponentPoints = context.FirstPlayerRoundPoints;
     this.PlayerPoints = context.SecondPlayerRoundPoints;
 }
Exemple #4
0
 public GameAction(Card opponent, Card player, PlayerTurnContext context, ICardTracker cardTracker)
 {
     this.OpponetCard    = opponent;
     this.PlayerCard     = player;
     this.PlayerTakes    = this.CheckIfPlayerTakes(opponent, player, context);
     this.HandValue      = opponent.GetValue() + player.GetValue();
     this.CardMaxWorth   = this.CardMaxWorthCalculator(player, cardTracker);
     this.OpponentPoints = context.FirstPlayerRoundPoints;
     this.PlayerPoints   = context.SecondPlayerRoundPoints;
 }
Exemple #5
0
 static ZatvorenoAI()
 {
     SummaryReport = new SummaryReport();
     Tracker       = new QuickSpecificCardSearchTracker();
     TrickDecisionMakerWhenSecond = new ShouldTake(Tracker);
     PossibleActionGenerator      = new PossibleActions(Tracker);
     ActionChoser   = new ChoseAction(PossibleActionGenerator, TrickDecisionMakerWhenSecond);
     CardStatistics = new CardStatisticsGenerator(Tracker);
     OptionEval     = new OptionEvaluator(Tracker, CardStatistics);
     CardChoser     = new FirstActionInTrickChoser(Tracker, OptionEval);
 }
        private int CardMaxWorthCalculator(Card player, ICardTracker cardTracker)
        {
            var worth = 0;

            worth += player.GetValue();

            var maxCardCanTake = cardTracker.AllCards[player.Suit].Where(x => x.Key > player.GetValue()
                && (x.Value == CardTracerState.Unknown || x.Value == CardTracerState.InOpponentHand)).ToList();

            if (maxCardCanTake.Count == 0)
            {
                return worth;
            }

            worth += maxCardCanTake.Max(x => x.Key);

            return worth;
        }
Exemple #7
0
        private int CardMaxWorthCalculator(Card player, ICardTracker cardTracker)
        {
            var worth = 0;

            worth += player.GetValue();

            var maxCardCanTake = cardTracker.AllCards[player.Suit].Where(x => x.Key > player.GetValue() &&
                                                                         (x.Value == CardTracerState.Unknown || x.Value == CardTracerState.InOpponentHand)).ToList();

            if (maxCardCanTake.Count == 0)
            {
                return(worth);
            }

            worth += maxCardCanTake.Max(x => x.Key);

            return(worth);
        }
 public CardEvaluatorWorthBased(ICardTracker tracker)
 {
     this.cardtracker = tracker;
 }
Exemple #9
0
 public ShouldTake(ICardTracker tracker)
 {
     this.cardTracker = tracker;
 }
Exemple #10
0
 public CardEvaluatorFirstPlayer(ICardTracker tracker)
 {
     this.cardtracker = tracker;
 }
 public FirstActionInTrickChoser(ICardTracker tracker, IOptionEvaluator evaluator)
 {
     this.cardTracker = tracker;
     this.optionEval  = evaluator;
 }
 public CardEvaluatorFirstPlayer(ICardTracker tracker)
 {
     this.cardtracker = tracker;
 }
Exemple #13
0
 public PossibleActions(ICardTracker cT)
 {
     this.cardTracker = cT;
 }
Exemple #14
0
 public CardStatisticsGenerator(ICardTracker cT)
 {
     this.cardTracker = cT;
 }
 public PossibleActions(ICardTracker cT)
 {
     this.cardTracker = cT;
 }
 public CardStatisticsGenerator(ICardTracker cT)
 {
     this.cardTracker = cT;
 }
 public OptionEvaluator(ICardTracker ct, ICardStatisticsGenerator st)
 {
     this.cardTracker = ct;
     this.statsGen = st;
 }
 public ShouldTake(ICardTracker tracker)
 {
     this.cardTracker = tracker;
 }
 public CardEvaluatorWorthBased(ICardTracker tracker)
 {
     this.cardtracker = tracker;
 }
Exemple #20
0
 public OptionEvaluator(ICardTracker ct, ICardStatisticsGenerator st)
 {
     this.cardTracker = ct;
     this.statsGen    = st;
 }