Ejemplo n.º 1
0
        public void Perft()
        {
            GameState gameState = GameStateBuilder.Build();
            string    txt       = File.ReadAllText(@"data/TestPositions.txt");

            string[]  positions   = txt.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            long      totalAmount = 0;
            Stopwatch watch       = new Stopwatch();

            watch.Start();
            foreach (string pos in positions)
            {
                string[] parts = pos.Split('|');
                gameState.LoadPosition(parts[0]);
                int amount = GenerateMoves(gameState, int.Parse(parts[1]));
                totalAmount += amount;
                int expectedAmount = int.Parse(parts[2]);
                Assert.AreEqual(expectedAmount, amount, $"Failed on position {parts[0]}, depth {parts[1]}");
            }
            watch.Stop();
            //nodes per second. worse than the actual value, because it only counts leaf nodes,
            //and it doesn't count variations ending in mate/stalemate before the requested depth
            double nps = totalAmount / ((double)watch.ElapsedMilliseconds / 1000);

            Console.WriteLine($"{nps} NPS");
        }
 public virtual void TestInit()
 {
     gameState  = GameStateBuilder.Build();
     evConfig   = new EvaluationConfig();
     evConfigPO = new PrivateObject(evConfig);
     evaluator  = new PositionEvaluatorWithStats(gameState, evConfig);
 }
Ejemplo n.º 3
0
        public void SpecificPosTest()
        {
            GameState gameState = GameStateBuilder.Build();
            string    fen       = "rnbqkbnr/p1pppppp/8/Pp6/8/8/1PPPPPPP/RNBQKBNR b KQkq - 0 2";

            gameState.LoadPosition(fen);
            List <Move> legalMoves = gameState.GetLegalMoves();
        }
Ejemplo n.º 4
0
 public void TestInit()
 {
     gameState        = GameStateBuilder.Build();
     zobristHashUtils = new PrivateObject(gameState.ZobristHashUtils);
 }