Ejemplo n.º 1
0
        private static void GradDown(Game[] games)
        {
            Game g = games[random.Next(0, games.Length)];

            double pred = 0f;

            for (int i = 0; i < 5; i++)
            {
                pred += g.TA[i].Quality;
                pred -= g.TB[i].Quality;
            }

            double diff = g.GoalDiff - pred;
            diff = diff / 1000f;

            int gameBoundary = 0;
            double teamAValids = 0;
            double teamBValids = 0;

            for (int i = 0; i < 5; i++)
                if (g.TA[i].GamesPlayed > gameBoundary)
                    teamAValids++;
            for (int i = 0; i < 5; i++)
                if (g.TB[i].GamesPlayed > gameBoundary)
                    teamBValids++;

            for (int i = 0; i < 5; i++)
            {
                if (g.TA[i].GamesPlayed > gameBoundary)
                    g.TA[i].Quality += (diff / teamAValids);

                if (g.TB[i].GamesPlayed > gameBoundary)
                    g.TB[i].Quality -= (diff / teamBValids);
            }
        }
Ejemplo n.º 2
0
        public IEnumerable<Game> LoadWithGamesOmmitted(int gamesToOmit)
        {
            List<Game> gamesOmmitted = new List<Game>();
            List<Game> gs = new List<Game>();

            StreamReader sr = new StreamReader(".\\..\\..\\..\\Results.csv");
            string contents = sr.ReadToEnd().Replace("\r", "");
            sr.Dispose();

            string[] x = contents.Split('\n');

            for (int i = 1; i < 1011; i++)
            {
                string name = x[i].Split(',')[0];
                if (!ps.ContainsKey(name))
                {
                    ps[name] = new Player(name, 0);
                    ps[name].GamesPlayed = 1;
                }
                else
                {
                    ps[name].GamesPlayed++;
                }
            }

            const int GameThreshold = 5;

            for (int i = 0; i < 101; i++)
            {
                Game g = new Game();
                g.GoalDiff = double.Parse(x[i * 10 + 1].Split(',')[2]);

                for (int a = 0; a < 5; a++)
                    g.TA[a] = ps[x[(i * 10) + a + 1].Split(',')[0]];
                for (int b = 0; b < 5; b++)
                    g.TB[b] = ps[x[(i * 10) + b + 6].Split(',')[0]];

                if (g.TA.All(z => z.GamesPlayed > 5) && g.TB.All(z => z.GamesPlayed > GameThreshold))
                    gs.Add(g);
            }

            Shuffle(gs);
            for(int i=0; i< gamesToOmit; i++)
            {
                Game g = gs.Last();
                gs.Remove(g);
                gamesOmmitted.Add(g);
            }

            Games = gs.ToArray();
            Players = ps.Where(z => z.Value.GamesPlayed > GameThreshold).Select(z => z.Value).ToArray();

            return gamesOmmitted;
        }
Ejemplo n.º 3
0
        public double Predict(Game g)
        {
            double pred = 0f;

            for (int i = 0; i < 5; i++)
            {
                pred += g.TA[i].Quality;
                pred -= g.TB[i].Quality;
            }

            return pred;
        }
Ejemplo n.º 4
0
        public double Predict(Game g)
        {
            double[] whoPlayed = new double[m_PlayerCount];

            for (int j = 0; j < m_PlayerCount; j++)
            {
                if (g.TA.Contains(m_Players[j])) whoPlayed[j] = 1;
                else if (g.TB.Contains(m_Players[j])) whoPlayed[j] = -1;
                else whoPlayed[j] = 0;
            }
            double predictedResult = CsvParser.RevConv(m_Bnn.ComputeOutputs(whoPlayed)[0]);

            return predictedResult;
        }
Ejemplo n.º 5
0
        private void BuildGameData(Game[] games, Player[] players)
        {
            m_PlayerCount = players.Count();
            Results = new double[games.Count()];
            WhoPlayed = new double[games.Count()][];

            for (int i = 0; i < games.Count(); i++)
            {
                Game g = games[i];
                Results[i] = CsvParser.Conv(g.GoalDiff);

                WhoPlayed[i] = new double[m_PlayerCount];
                for (int j = 0; j < m_PlayerCount; j++)
                {
                    if (g.TA.Contains(players[j])) WhoPlayed[i][j] = 1;
                    else if (g.TB.Contains(players[j])) WhoPlayed[i][j] = -1;
                    else WhoPlayed[i][j] = 0;
                }
            }
        }