コード例 #1
0
ファイル: BoardTest.cs プロジェクト: labattbatman/CamelUpData
        private void AssertEv(Ev aEv, GameRules.PlayerAction aAction, float a2DecimalEv, object aInfo)
        {
            var evDiff = Math.Abs(Math.Round(aEv.m_Ev, 2) - a2DecimalEv);

            Assert.AreEqual(aEv.m_PlayerAction, aAction);
            Assert.IsTrue(evDiff < 0.01, aAction + " EvDiff is: " + evDiff);
            Assert.AreEqual(aEv.m_Info, aInfo);
        }
コード例 #2
0
        private Ev GenerateShortTermCardEv()
        {
            var highestCamelEv = m_CamelRankManager.GetHighestEv(m_CamelCards);
            Ev  retval         = new Ev
            {
                m_PlayerAction = GameRules.PlayerAction.PickShortTermCard,
                m_Ev           = highestCamelEv.Item2,
                m_Info         = GameRules.FullNameCamel(highestCamelEv.Item1)
            };

            return(retval);
        }
コード例 #3
0
        public Ev GetEv()
        {
            Dictionary <char, double[]> camelRanks          = GetAverageCamelRankInfo();
            Tuple <char, double>        highestEvFirstPlace = new Tuple <char, double>('x', -10f);
            Tuple <char, double>        highestEvLastPlace  = new Tuple <char, double>('x', -10f);

            foreach (var cr in camelRanks)
            {
                double ev = LongTermCardGuesser.Instance.GetPriceForFirst(cr.Key) * cr.Value[0];
                if (ev > highestEvFirstPlace.Item2)
                {
                    highestEvFirstPlace = new Tuple <char, double>(cr.Key, ev);
                }

                ev = LongTermCardGuesser.Instance.GetPriceForLast(cr.Key) * cr.Value[4];                //todo magic number
                if (ev > highestEvLastPlace.Item2)
                {
                    highestEvLastPlace = new Tuple <char, double>(cr.Key, ev);
                }
            }

            Tuple <char, double> highest;
            bool isFirst;

            if (highestEvFirstPlace.Item2 > highestEvLastPlace.Item2)
            {
                highest = highestEvFirstPlace;
                isFirst = true;
            }
            else
            {
                highest = highestEvLastPlace;
                isFirst = false;
            }

            string info = String.Format("{0} cards pour le {1}, avec une proportion de {2}",
                                        isFirst? "First" : "Last", GameRules.FullNameCamel(highest.Item1), GetTotalProportionAllRankManagers);

            Ev retval = new Ev
            {
                m_PlayerAction = GameRules.PlayerAction.PickLongTermCard,
                m_Ev           = (float)highest.Item2,
                m_Info         = info
            };

            return(retval);
        }
コード例 #4
0
        private Ev GeneratePutTrapEv()
        {
            List <int> highestCases = new List <int> {
                0
            };

            for (int i = 0; i < m_CasesLandedOn.Length; i++)
            {
                if (m_CasesLandedOn[i] >= m_CasesLandedOn[highestCases[0]])
                {
                    if (m_CasesLandedOn[i] > m_CasesLandedOn[highestCases[0]])
                    {
                        highestCases.Clear();
                    }

                    highestCases.Add(i);
                }
            }

            string casesRank = string.Empty;

            for (int i = 0; i < highestCases.Count; i++)
            {
                if (i != 0)
                {
                    casesRank += ", ";
                }
                casesRank += highestCases[i];
            }

            Ev retval = new Ev
            {
                m_PlayerAction = GameRules.PlayerAction.PutTrap,
                m_Ev           = (float)m_CasesLandedOn[highestCases[0]] / (float)m_TotalSubBoardWithWeight * GameRules.TRAP_REWARD,
                m_Info         = string.Format("Case(s): {0}. Minus Trap. Pas EV exacte.", casesRank)
            };

            return(retval);
        }
コード例 #5
0
        public override string ToString()
        {
            string retval = string.Format("\n\nAnalyze of {0} boards with a weight of {1}\n", m_Boards.Count, m_TotalSubBoardWithWeight);

            retval += "---------------------------------\n";

            //retval += m_CamelRankManager.ToString(m_CamelCards);

            retval += "---------------------------------\n";

            retval += string.Format("Highest card short term is\nEV: {1} {0}\n\n", m_Evs[0].m_Info, m_Evs[0].m_Ev.ToString("N2"));
            retval += string.Format("HighestCase               \nEV: {1} {0}\n\n", m_Evs[1].m_Info, m_Evs[1].m_Ev.ToString("N2"));
            retval += string.Format("Highest card long term is \nEV: {1} {0}\n\n", m_Evs[2].m_Info, m_Evs[2].m_Ev.ToString("N2"));
            retval += string.Format("RollDice                  \nEV: {0} {1}\n\n", m_Evs[3].m_Ev.ToString("N2"), m_Evs[3].m_Info);

            retval += "---------------------------------\n";
            retval += "---------------------------------\n";

            Ev biggestEv = GetSortedtEvs()[0];

            retval += string.Format("BestAction: {0} EV: {1}. {2} \n", biggestEv.m_PlayerAction, biggestEv.m_Ev.ToString("N2"), biggestEv.m_Info);

            return(retval);
        }
コード例 #6
0
        private Ev GenerateRollDiceEv()
        {
            float evNextTurn = 0;

            foreach (var camel in GameRules.IDENTITY_CAMEL_NAME_UNROLLED)
            {
                if (m_OriginBoard.Contains(camel.ToString()))
                {
                    evNextTurn += new BoardAnalyzer(m_OriginBoard, m_Boards, m_CamelCardString, camel.ToString()).GetSortedtEvs()[0].m_Ev;
                }
            }


            evNextTurn = evNextTurn / GameRules.IDENTITY_CAMEL_NAME_UNROLLED.Length;
            float secondEv = GetSortedtEvs()[1].m_Ev;

            Ev retval = new Ev
            {
                m_PlayerAction = GameRules.PlayerAction.RollDice,
                m_Ev           = GameRules.TRAP_REWARD - (evNextTurn - secondEv)
            };

            return(retval);
        }