示例#1
0
        static void Main(string[] args)
        {
            Tuple <string, string>[] selectionRules = GetRules("D:\\C#\\FootballBets\\Rules.csv");
            Dictionary <string, Dictionary <string, string> > selectionRulesTable = GetRulesTable("D:\\C#\\FootballBets\\RulesTable.csv");
            Dictionary <string, TeamFootball[]> groups = GetGroups("D:\\C#\\FootballBets\\Teams.csv");

            int[]       prices      = { 1000, 500, 250, 250, 125, 125, 125, 125, 50, 50, 50, 50, 50, 50, 50, 50, 25, 25, 25, 25, 25, 25, 25, 25 };
            int         nIterations = 1000000;
            MethodToUse goaslMethod = MethodToUse.quickWeighted;

            Dictionary <string, float> mcFinalPrices = groups.SelectMany(x => x.Value).ToDictionary(x => x.Name, x => 0f);

            Competition euro2016 = new Competition(groups, selectionRules, selectionRulesTable, goaslMethod);

            TeamFootball[] result;
            for (int iteration = 0; iteration < nIterations; iteration++)
            {
                result = euro2016.PlayCompetition();
                for (int j = 0; j < result.Length; j++)
                {
                    mcFinalPrices[result[j].Name] += prices[j];
                }
                if (iteration % (nIterations / 10) == 0)
                {
                    Console.WriteLine(iteration / (nIterations / 100) + "%");
                }
                euro2016.Reset();
            }

            foreach (var team in mcFinalPrices.OrderByDescending(x => x.Value))
            {
                Console.WriteLine("{0} = {1}$", team.Key, team.Value / nIterations);
                //Console.WriteLine(team.Value/nIterations);
            }
            Console.ReadLine();
        }
示例#2
0
        public static void ReworkTeamPoints(Dictionary <string, TeamFootball[]> groups, MethodToUse method)
        {
            List <float> pointsList = new List <float>();

            foreach (TeamFootball team in groups.SelectMany(x => x.Value))
            {
                pointsList.Add(team.Points);
            }
            switch (method)
            {
            case MethodToUse.stupid:
                Tuple <double, double> meanVar = Statistics.MeanVariance(pointsList);
                foreach (TeamFootball team in groups.SelectMany(x => x.Value))
                {
                    team.Points = (team.Points - (float)meanVar.Item1) / (float)meanVar.Item2;
                }
                break;

            default:
                break;
            }
        }
示例#3
0
 public GoalsModel(MethodToUse method, Random rand)
 {
     Method = method;
     Rand   = rand;
 }
示例#4
0
 public Competition(Dictionary <string, TeamFootball[]> groups, Tuple <string, string>[] selectionRules,
                    Dictionary <string, Dictionary <string, string> > selectionRulesTable, MethodToUse methodToUse = MethodToUse.none)
 {
     nTeams = 0;
     foreach (KeyValuePair <string, TeamFootball[]> group in groups)
     {
         nTeams += group.Value.Length;
     }
     MatchesKnockout     = new Tuple <TeamFootball, TeamFootball> [15];
     Groups              = new Dictionary <string, TeamFootball[]>();
     Groups              = groups;
     SelectionRules      = selectionRules;
     SelectionRulesTable = selectionRulesTable;
     Goals = new GoalsModel(methodToUse);
 }
示例#5
0
 public GoalsModel(MethodToUse method)
 {
     Method = method;
     Rand   = new Random();
 }