Пример #1
0
        /// <summary>
        /// Null if moves are not part any known opening
        /// </summary>
        /// <param name="previousMoves"></param>
        /// <returns></returns>
        public SingleMove?NextMove(IList <SingleMove> previousMoves)
        {
            if (!previousMoves.Any())
            {
                // Pick random opening strategy, white move
                var index    = _random.Next(Openings.Count);
                var strategy = Openings[index];

                Diagnostics.AddMessage($"Chosen opening strategy: {strategy.Name}. ");
                return(strategy.Moves.First());
            }
            else
            {
                // Check if there is one or many possible opening strategies and pick random
                var similarOpenings = OpeningsWithSameMoves(previousMoves);
                if (similarOpenings.Count == 0)
                {
                    return(null);
                }

                // Pick random continuation
                var index    = _random.Next(similarOpenings.Count);
                var strategy = similarOpenings[index];

                Diagnostics.AddMessage($"Using opening strategy {strategy.Name}. ");
                return(strategy.Moves[previousMoves.Count]);
            }
        }
Пример #2
0
        private static void AddIterativeDeepeningResultDiagnostics(int depthUsed, int totalMoveCount, int searchMoveCount, double evaluation, SingleMove?move = null, Board?board = null)
        {
            if (searchMoveCount < totalMoveCount)
            {
                Diagnostics.AddMessage($" Iterative deepening search depth was {depthUsed - 1} [partial {depthUsed}: ({searchMoveCount}/{totalMoveCount})].");
            }
            else
            {
                Diagnostics.AddMessage($" Iterative deepening search depth was {depthUsed} ({searchMoveCount}/{totalMoveCount}).");
            }
            Diagnostics.AddMessage($" Move evaluation: {evaluation}.");

            // DEBUG
            if (move != null && board != null && board.Strategic.EndGameWeight > 0.50)
            {
                var newBoard = new Board(board, move);
                var isWhite  = newBoard.ValueAtDefinitely(move.NewPos).IsWhite;
                Diagnostics.AddMessage(" EndGameKingToCornerEvaluation: " + newBoard.EndGameKingToCornerEvaluation(isWhite));
            }
        }