コード例 #1
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;
        }
コード例 #2
0
ファイル: Neural.cs プロジェクト: JasonCrease/FootballDescent
        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;
                }
            }
        }