Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var reader = new PgnReader();

            var gamesCollection = reader.ReadGamesFromFile(@"c:\tmp\millionbase-2.22.pgn"); 

            int count = 0;
            var start = DateTime.Now;
            foreach (var item in gamesCollection)
            {
                if (++count % 100 == 0)
                {
                    Console.WriteLine();
                    var now = DateTime.Now;
                    var timespan = now - start;
                    var gamesPerSecond = ((double)count) / timespan.TotalSeconds;
                    Console.SetCursorPosition(1, 0);
                    Console.WriteLine("Time passed: {0}. Games: {1}, Games per Second: {2}", timespan, count, gamesPerSecond);
                    if (count > 10000)
                        break;
                }
            }

            Console.ReadKey();
        }
Ejemplo n.º 2
0
 public IEnumerable<Game> ParseStream(Stream stream)
 {
     var parser = new PgnReader();
     var db = parser.ReadFromStream(stream);
     foreach (var game in db.Games)
     {
         yield return Mapper.Map<Game>(game);
     }
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            var reader = new PgnReader();

            var db = reader.ReadFromFile("Tarrasch.pgn");
            var game = db.Games[0];

            Console.WriteLine("{0} vs {1} in {2} ({3})\n", game.WhitePlayer, game.BlackPlayer, game.Site, game.Year);


            if (game.Result == GameResult.White)
                Console.WriteLine("\nWhite wins in {0} moves.", game.MoveText.FullMoveCount);
            else if (game.Result == GameResult.Black)
                Console.WriteLine("\nBlack wins in {0} moves.", game.MoveText.FullMoveCount);
            else if (game.Result == GameResult.Draw)
                Console.WriteLine("\nGame ends in a draw.");
            else
                Console.WriteLine("\nGame not unfinshed.");

            Console.WriteLine();

            Console.ReadKey();
        }
Ejemplo n.º 4
0
 public async Task<IEnumerable<Game>> ParseAsync(string text)
 {
     var parser = new PgnReader();
     var db = await Task.Run(() => { return parser.ReadFromString(text); });
     return Mapper.Map<IEnumerable<Game>>(db);
 }