예제 #1
0
        /// <summary>
        /// Writes a <see cref="Position"/> object to the file.
        /// </summary>
        /// <param name="writer">The file writer.</param>
        /// <param name="position">The position to write (writes <see cref="PersistenceConstants.NullValue"/> if null).</param>
        private void WritePosition(StreamWriter writer, Position?position)
        {
            if (!position.HasValue)
            {
                writer.WriteLine(PersistenceConstants.NullValue);
                return;
            }

            writer.WriteLine(PositionConverter.ToString(position.Value));
        }
예제 #2
0
        /// <summary>
        /// Runs AI calculation and applies best move to the bitboard.
        /// </summary>
        /// <returns>The response (best move).</returns>
        private string CalculateAIMove()
        {
            var aiResult = _gameSession.MoveAI(_engineColor);

            if (aiResult == null)
            {
                return(null);
            }

            var fromConverted = PositionConverter.ToString(aiResult.PVNodes[0].From);
            var toConverted   = PositionConverter.ToString(aiResult.PVNodes[0].To);

            _csvLogger.WriteLine(aiResult, _gameSession.Bitboard);
            return($"{fromConverted}{toConverted}");
        }