private static void ExecuteTestForFenAndDepth(
            string fen,
            int maxPlyDepth,
            [CanBeNull] GameMove expectedBestMove)
        {
            var currentMethodName = MethodBase.GetCurrentMethod().GetQualifiedName();

            Console.WriteLine(
                @"[{0}] Executing the test for '{1}' with max ply depth {2}...",
                currentMethodName,
                fen,
                maxPlyDepth);

            var gameBoard = new GameBoard(fen);

            var playerParameters = new EnginePlayerParameters
            {
                MaxPlyDepth           = maxPlyDepth,
                UseOpeningBook        = false,
                MaxTimePerMove        = null,
                UseMultipleProcessors = false,
                UseTranspositionTable = false
            };

            var player = new EnginePlayer(FakeLogger.Instance, FakeOpeningBookProvider.Instance, gameBoard.ActiveSide, playerParameters);

            var stopwatch       = Stopwatch.StartNew();
            var gameControlStub = new GameControl();
            var request         = new GetMoveRequest(gameBoard, CancellationToken.None, gameControlStub);
            var task            = player.CreateGetMoveTask(request);

            task.Start();
            var principalVariationInfo = task.Result;

            stopwatch.Stop();

            Console.WriteLine(
                @"[{0} @ {1}] ({2}) Time {3}, PV {{{4}}}, max ply depth {5}.",
                currentMethodName,
                DateTimeOffset.Now.ToFixedString(),
                ChessHelper.PlatformVersion,
                stopwatch.Elapsed,
                principalVariationInfo,
                player.MaxPlyDepth);

            Console.WriteLine();

            Assert.That(principalVariationInfo, Is.Not.Null);

            if (expectedBestMove != null)
            {
                Assert.That(principalVariationInfo.FirstMove, Is.EqualTo(expectedBestMove));
            }
        }
Exemple #2
0
        internal BoardState(Deck deck, Dictionary <Destination, Stack <Card> > discards, EnginePlayer you, EnginePlayer them)
        {
            CardsRemaining = deck.Count;

            Discards = new Dictionary <Destination, Card>(discards.Keys.Count);

            foreach (var destination in discards.Keys)
            {
                var cards = discards[destination];
                if (cards.Any())
                {
                    Discards.Add(destination, cards.Peek());
                }
            }

            YourExpeditions  = you.GetExpeditions();
            TheirExpeditions = them.GetExpeditions();

            YourCards = you.Cards.ToList();
        }