Beispiel #1
0
        private void sortPlayers(POSITIONS pos, List <Player> players)
        {
            IRankDefScorer scorer = RankDepthFactory.createDepthFactory(RankDepthFactory.DEPTH_ALGO.READ);

//            IRankDefScorer scorer = RankDepthFactory.createDepthFactory(RankDepthFactory.DEPTH_ALGO.SOMWORD);

            players.Sort(delegate(Player p1, Player p2)
            {
                double p1Score = 0;
                double p2Score = 0;

                switch (pos)
                {
                case POSITIONS.CATCHER:
                    //     p1Score = scorer.calculateFirstBaseDefScore(p1.Def.getDefRating(p1.Def.CatcherRating), p1.Def.getERating(p1.Def.CatcherRating));
                    //      p2Score = scorer.calculateFirstBaseDefScore(p2.Def.getDefRating(p2.Def.CatcherRating), p2.Def.getERating(p2.Def.CatcherRating));
                    break;

                case POSITIONS.FIRSTBASE:
                    p1Score = scorer.calculateFirstBaseDefScore(p1.Def.getDefRating(p1.Def.FirstBaseRating), p1.Def.getERating(p1.Def.FirstBaseRating));
                    p2Score = scorer.calculateFirstBaseDefScore(p2.Def.getDefRating(p2.Def.FirstBaseRating), p2.Def.getERating(p2.Def.FirstBaseRating));
                    break;

                case POSITIONS.SECONDBASE:
                    p1Score = scorer.calculateSecondBaseDefScore(p1.Def.getDefRating(p1.Def.SecondBaseRating), p1.Def.getERating(p1.Def.SecondBaseRating));
                    p2Score = scorer.calculateSecondBaseDefScore(p2.Def.getDefRating(p2.Def.SecondBaseRating), p2.Def.getERating(p2.Def.SecondBaseRating));
                    break;

                case POSITIONS.THIRDBASE:
                    p1Score = scorer.calculateThirdBaseDefScore(p1.Def.getDefRating(p1.Def.ThirdBaseRating), p1.Def.getERating(p1.Def.ThirdBaseRating));
                    p2Score = scorer.calculateThirdBaseDefScore(p2.Def.getDefRating(p2.Def.ThirdBaseRating), p2.Def.getERating(p2.Def.ThirdBaseRating));
                    break;

                case POSITIONS.SHORTSTOP:
                    p1Score = scorer.calculateShortStopDefScore(p1.Def.getDefRating(p1.Def.ShortstopRating), p1.Def.getERating(p1.Def.ShortstopRating));
                    p2Score = scorer.calculateShortStopDefScore(p2.Def.getDefRating(p2.Def.ShortstopRating), p2.Def.getERating(p2.Def.ShortstopRating));
                    break;

                case POSITIONS.LEFTFIELD:
                    p1Score = scorer.calculateLeftFieldDefScore(p1.Def.getDefRating(p1.Def.LeftFieldRating), p1.Def.getERating(p1.Def.LeftFieldRating));
                    p2Score = scorer.calculateLeftFieldDefScore(p2.Def.getDefRating(p2.Def.LeftFieldRating), p2.Def.getERating(p2.Def.LeftFieldRating));
                    break;

                case POSITIONS.CENTERFIELD:
                    p1Score = scorer.calculateCenterFieldDefScore(p1.Def.getDefRating(p1.Def.CenterFieldRating), p1.Def.getERating(p1.Def.CenterFieldRating));
                    p2Score = scorer.calculateCenterFieldDefScore(p2.Def.getDefRating(p2.Def.CenterFieldRating), p2.Def.getERating(p2.Def.CenterFieldRating));
                    break;

                case POSITIONS.RIGHTFIELD:
                    p1Score = scorer.calculateRightFieldDefScore(p1.Def.getDefRating(p1.Def.RightFieldRating), p1.Def.getERating(p1.Def.RightFieldRating));
                    p2Score = scorer.calculateRightFieldDefScore(p2.Def.getDefRating(p2.Def.RightFieldRating), p2.Def.getERating(p2.Def.RightFieldRating));
                    break;
                }
                return(p1Score.CompareTo(p2Score));
            });
        }
        public void testRightField()
        {
            List <TestItem> testCases = new List <TestItem>();

            testCases.Add(TestItem.create(2, 10, 0, 10.0));
            testCases.Add(TestItem.create(2, 10, -1, 9));
            testCases.Add(TestItem.create(2, 10, -2, 8));
            testCases.Add(TestItem.create(2, 10, -3, 7));
            testCases.Add(TestItem.create(2, 10, -4, 6));
            testCases.Add(TestItem.create(2, 10, 4, 14));
            testCases.Add(TestItem.create(2, 10, 3, 13));
            testCases.Add(TestItem.create(2, 10, 2, 12));
            testCases.Add(TestItem.create(2, 10, 1, 11));
            testCases.Add(TestItem.create(2, 20, -4, 20.1));
            testCases.Add(TestItem.create(2, 20, -3, 21.1));
            testCases.Add(TestItem.create(2, 20, -2, 22.1));
            testCases.Add(TestItem.create(2, 20, -1, 23.1));
            testCases.Add(TestItem.create(2, 20, 0, 24.1));
            testCases.Add(TestItem.create(2, 20, 1, 25.1));
            testCases.Add(TestItem.create(2, 20, 2, 26.1));
            testCases.Add(TestItem.create(2, 20, 3, 27.1));
            testCases.Add(TestItem.create(3, 20, -4, 34.3));
            testCases.Add(TestItem.create(3, 20, -3, 35.3));
            testCases.Add(TestItem.create(3, 20, -2, 36.3));
            testCases.Add(TestItem.create(3, 20, -1, 37.3));

            foreach (TestItem item in testCases)
            {
                double result = scorer.calculateRightFieldDefScore(item.Range, item.EFact, item.ThrowingArm);
                Assert.AreEqual(item.Expect, Math.Round(result, 1), item.ToString());
            }
        }
        public void testRightField()
        {
            List <TestItem> testCases = new List <TestItem>();

            testCases.Add(TestItem.create(1, 10, 10));
            testCases.Add(TestItem.create(2, 10, 18.4));
            testCases.Add(TestItem.create(3, 10, 26.8));
            testCases.Add(TestItem.create(4, 10, 40.8));
            testCases.Add(TestItem.create(1, 20, 20));
            testCases.Add(TestItem.create(2, 20, 28.4));
            testCases.Add(TestItem.create(3, 20, 36.8));
            testCases.Add(TestItem.create(4, 20, 50.8));
            testCases.Add(TestItem.create(5, 20, 62));

            foreach (TestItem item in testCases)
            {
                double result = scorer.calculateRightFieldDefScore(item.Range, item.EFact, 0);
                Assert.AreEqual(item.Expect, result, item.ToString());
            }
        }