static void Main(string[] args) { if (args.Length == 0) { args = SetArgsByDefault(); } Program.args = args; if (Program.args.Length > 0 && args[0].ToLower() == "help") { Console.WriteLine("Модули:"); Console.WriteLine("parsehero:\t загружает информацию о героях"); Console.WriteLine("<i=источник> [o=результат]"); Console.WriteLine("parseherowithalias:\t загружает информацию о героях и псевдонимах"); Console.WriteLine("<источник> <источник псевдонимов> [результат] [результат псевдонимов]"); return; } switch (args[0].ToLower()) { case "parsehero": new Service.HeroParser().Run(args); break; case "parseherowithalias": new Service.HeroParserWithMapper().Run(args); break; case "parsemap": new Service.MapParser().Run(args); break; case "parsemapwithalias": new Service.MapParserWithAlias().Run(args); break; case "parsereplay": var x = new Service.ReplayParser(); x.Run(args); break; case "parsematches": new Service.MatchParserStat().Run(args); break; case "stattoexcel": SaveTOExcelCSVFormat(); break; case "makeguid": new Service.GuidMaker().Run(args); break; case "nnparser": new Service.NNParser().Run(args); break; case "nnparser2": new Service.NNParser2().Run(args); break; case "subgroupparser": new Service.SubgroupParser().Run(args); break; case "nnparserboth": new Service.NNParserBoth().Run(args); break; case "subgroupparserwithoutmap": new Service.SubgroupParserWithoutMap().Run(args); break; case "autoparser": new Service.AutoParser().Run(args); break; } }
public override void Run(string[] args) { base.Run(args); Validate(); rParser.Run(args); Statistic[] stat = new Statistic[rParser.MapCount + 1]; OpenSource(inputFolder); object data; int i = 0; List <Tuple <int, int, int> > temps = new List <Tuple <int, int, int> >(); Dictionary <Match, double> result = new Dictionary <Match, double>(); Console.WriteLine("Парсинг матчей"); int heroCount = 0; int lastMatchId = -1; while ((data = ReadData()) != null) { var r = ParseData(data); if (r.Item1 == -1) { continue; } if (lastMatchId == r.Item1) { continue; } temps.Add(ParseData(data)); i++; //собираем части воедино if (i == 10) { i = 0; bool flag = false; for (int j = 0; j < 9; j++) { if (temps[j].Item1 != temps[j + 1].Item1) { flag = true; break; } } if (flag == true) { temps.Clear(); continue; } Match m = new Match(); m.Map = rParser.ReplayResult[temps[0].Item1]; m.ProbabilityToWin = 1; int first_i = 0, second_i = 0; for (int j = 0; j < temps.Count; j++) { if (temps[j].Item3 == 1) { m.YourTeam[first_i++] = temps[j].Item2; } else { m.EnemyTeam[second_i++] = temps[j].Item2; } if (temps[j].Item2 > heroCount) { heroCount = temps[j].Item2; } } //обратное Match temp_m = new Match() { YourTeam = m.EnemyTeam, EnemyTeam = m.YourTeam, Map = m.Map }; //пробуем добавить //если запись уже есть if (result.ContainsKey(m)) { //усредняем вероятность double used = result[m]; double newer = m.ProbabilityToWin; double rez = (used + newer) / 2; result[m] = rez; Console.WriteLine(m.ToString() + " Уже существует"); } //если есть противоречие else if (result.ContainsKey(temp_m)) { //усредняем вероятность double used = result[m]; double newer = 1 - m.ProbabilityToWin; double rez = (used + newer) / 2; result[m] = rez; } else { result.Add(m, m.ProbabilityToWin); if (result.Count % 100000 == 0) { Console.WriteLine("Уже обработано " + result.Count); } } lastMatchId = temps.Last().Item1; temps.Clear(); } } Save(output, result, typeof(Dictionary <Match, double>)); for (int j = 0; j < stat.Length; j++) { stat[j] = new Statistic() { Statictic = new StatisticItem() { Matches = new int[heroCount + 1], Wins = new int[heroCount + 1] } }; } Console.WriteLine("Расчет статистики матчей"); ///считаем сколько матчей на каждой карте foreach (var it in rParser.ReplayResult) { stat[it.Value].Statictic.Ammount++; } //данные собраны,считаем статистику Console.WriteLine("Расчет статистики героев"); foreach (var it in result) { Match cur = it.Key; for (int j = 0; j < 5; j++) { stat[cur.Map].Statictic.Matches[cur.YourTeam[j]]++; stat[cur.Map].Statictic.Wins[cur.YourTeam[j]]++; } for (int j = 0; j < 5; j++) { stat[cur.Map].Statictic.Matches[cur.EnemyTeam[j]]++; } } File.WriteAllText(statisticOutput, JSonParser.Save(stat, typeof(Statistic[])), Encoding.Default); Console.WriteLine("Успешно спарсено " + result.Count + " записей"); }