Exemplo n.º 1
0
        public static void TrainModelAt(BasicNetwork net, int gameNumber)
        {
            Console.WriteLine($"Training at {gameNumber}");
            string path     = Directory.GetCurrentDirectory() + @"\..\..\Model";
            string dataPath = Directory.GetCurrentDirectory() + @"\..\..\Data";

            //Check if data is already saved
            //if not null then parse
            OPSData data = OPSData.GetData(dataPath, "data");
            OPSGame game;

            //Check if not empty game and not already added to data
            if (data.GetGame(gameNumber) == null && !data.emptyGames.Contains(gameNumber))
            {
                game = Parser.ParseUrl(gameNumber);
                if (game != null)
                {
                    data.AddGame(game);
                }
                else
                {
                    data.AddEmptyGame(gameNumber);
                }
            }
            else
            {
                game = data.GetGame(gameNumber);
            }

            if (game == null)
            {
                Console.WriteLine(gameNumber + " was empty");
                return;
            }

            net.FeedForward(ToFloatArray(game.PlayerOPS));
            net.BackProp(ToFloatArray(game.TeamScores));

            net.SaveModel(path);
            data.SaveData(dataPath, "data");

            Console.WriteLine("Train sucessful!");
        }
Exemplo n.º 2
0
        public static void GetDataThrough(int minGameNumber, int maxGameNumber)
        {
            string dataPath = Directory.GetCurrentDirectory() + @"\..\..\Data";

            // If min and max is fliped
            if (minGameNumber > maxGameNumber)
            {
                int temp = maxGameNumber;
                maxGameNumber = minGameNumber;
                minGameNumber = temp;
            }

            Console.WriteLine("=========>Starting to collect data<=========");
            for (int i = maxGameNumber; i >= minGameNumber; i--)
            {
                Console.WriteLine($"Getting game data for {i}...");
                OPSData data = OPSData.GetData(dataPath, "data");

                // Check if there is no game data and is not empty game
                if (data.GetGame(i) == null && !data.emptyGames.Contains(i))
                {
                    // Parse Game and update it to the data
                    OPSGame game = Parser.ParseUrl(i);

                    if (game != null)
                    {
                        data.AddGame(game);
                        Console.WriteLine(" > Adding game stats.");
                    }
                    else
                    {
                        data.AddEmptyGame(i);
                        Console.WriteLine(" > Adding empty game");
                    }

                    data.SaveData(dataPath, "data");
                }
                Console.WriteLine($"Data updated for {i}...");
            }
        }