Exemple #1
0
        public static Dictionary <Bid, int> SolveSingleDummy(string northHand, SouthInformation southInformation, int numberOfHands, Dictionary <Suit, Player> declarers)
        {
            var tricksPerContract = new Dictionary <Bid, int>();
            var shufflingDeal     = new ShufflingDeal
            {
                North = new North {
                    Hand = northHand.Split(',')
                },
                South = new South {
                    Controls = southInformation.Controls, Hcp = southInformation.Hcp, Queens = southInformation.Queens
                },
                NrOfHands = numberOfHands
            };

            foreach (var shape in southInformation.Shapes)
            {
                shufflingDeal.South.Shape = shape;

                if (southInformation.SpecificControls == null)
                {
                    ShuffleAndUpdate(shufflingDeal, shape);
                }
                else
                {
                    foreach (var specificControls in southInformation.SpecificControls)
                    {
                        shufflingDeal.South.SpecificControls = specificControls;
                        ShuffleAndUpdate(shufflingDeal, shape);
                    }
                }
            }
            return(tricksPerContract);

            void ShuffleAndUpdate(ShufflingDeal shufflingDeal, string shape)
            {
                var handsForSolver = shufflingDeal.Execute();

                // TODO extend for multiple trump suits and for NT
                var(suit, length) = Util.GetLongestSuitShape(northHand, shape);
                CalculateAndUpdateDictionary(handsForSolver, length >= 8 ? suit : Suit.NoTrump);
            }

            void CalculateAndUpdateDictionary(IEnumerable <string> handsForSolver, Suit suit)
            {
                foreach (var trick in Api.SolveAllBoards(handsForSolver, Util.GetDDSSuit(suit), Util.GetDDSFirst(declarers[suit])))
                {
                    tricksPerContract.AddOrUpdateDictionary(new Bid(trick - 6, suit));
                }
            }
        }
Exemple #2
0
        private static IEnumerable <string> GetHandsForSolverExactHands(string northHandStr, string southHandStr)
        {
            var shufflingDeal = new ShufflingDeal
            {
                North = new North {
                    Hand = northHandStr.Split(',')
                },
                South = new South {
                    Hand = southHandStr.Split(',')
                }
            };

            return(shufflingDeal.Execute());
        }