Exemplo n.º 1
0
        public void TestLongTermBoardAnalyzerRank()
        {
            string testBoard = ";;;;;;;;;;;;;;O;B;WY;;G;";

            var ltbm   = new LongTermBoardAnalyser(new Board(testBoard), null);
            var actual = ltbm.GetAverageCamelRankInfo();

            var bmm = new BoardManager(10);

            bmm.CreateBoard(testBoard);
            var rankCamels = new CamelRankManager(bmm.GetAllBoards()).GetCamelRanks;

            var expected = new Dictionary <char, double[]>();

            foreach (var rankCamel in rankCamels)
            {
                var rank = new double[5];

                for (int i = 0; i < 5; i++)
                {
                    rank[i] = (double)rankCamel.TimeFinish(i) / rankCamel.m_TotalFinish;
                }

                expected.Add(rankCamel.CamelName, rank);
            }

            for (int i = 0; i < 5; i++)
            {
                var total = 0.0;

                foreach (var exp in expected)
                {
                    total += exp.Value[i];
                }

                Assert.IsTrue(Math.Abs(1 - total) < 0.01, i.ToString());
            }

            foreach (var exp in expected)
            {
                for (int i = 0; i < exp.Value.Length; i++)
                {
                    Assert.IsTrue(Math.Abs(exp.Value[i] - actual[exp.Key][i]) < 0.001, String.Format("Camel {0}, position {1}. Exp: {2} Act:{3}", exp.Key, i, exp.Value[i], actual[exp.Key][i]));
                }
            }
        }
Exemplo n.º 2
0
        private Ev GenerateLongTermCardEv()
        {
            LongTermBoardAnalyser ltba = new LongTermBoardAnalyser(new Board(m_OriginBoard), ClearDictionaries);

            return(ltba.GetEv());
        }