コード例 #1
0
 public SimpleMoveEstimator(GameSetting setting, IBoardEvaluator boardEvaluator, IMoveNominator moveNominator, int maxDepth)
 {
     this.Setting        = setting;
     this.boardEvaluator = boardEvaluator;
     this.moveNominator  = moveNominator;
     this.maxDepth       = maxDepth;
 }
コード例 #2
0
ファイル: ConfigManager.cs プロジェクト: Spongie/Chess
        public static ConcurrentDictionary <EvalCacheKey, float> LoadCache(IBoardEvaluator boardEvaluator, int depth, Color color)
        {
            string directory = $"BotConfigs\\Cache\\";

            CreateDirectoryIfNotExists(directory);

            if (boardEvaluator == null || !File.Exists(directory + boardEvaluator.GetBotId(depth) + ".cache"))
            {
                return(new ConcurrentDictionary <EvalCacheKey, float>());
            }

            var xmlSerializer = new XmlSerializer(typeof(List <CacheFileEntry>));
            var cacheList     = (List <CacheFileEntry>)xmlSerializer.Deserialize(File.OpenRead(directory + boardEvaluator.GetBotId(depth) + ".cache"));

            var cache = new ConcurrentDictionary <EvalCacheKey, float>();

            foreach (var cacheFileEntry in cacheList)
            {
                cache.TryAdd(cacheFileEntry.CacheKey, cacheFileEntry.Score);
            }

            return(cache);

            //return
            //    JsonConvert.DeserializeObject<ConcurrentDictionary<EvalCacheKey, float>>(
            //        File.ReadAllText(directory + boardEvaluator.GetBotId(depth) + ".cache"));
        }
コード例 #3
0
 public ChessBot(IBoardEvaluator evaluator, int depth, Color color)
 {
     Color          = color;
     boardEvaluator = evaluator;
     maxDepth       = depth;
     boardEvalCache = new ConcurrentDictionary <EvalCacheKey, float>(ConfigManager.LoadCache(boardEvaluator, maxDepth, Color));
 }
コード例 #4
0
 public EvaluatorTreeSearchPreplacer(IBoardEvaluator boardEvaluator, int depth, int branching, bool scoreFinalState)
 {
     _boardEvaluator  = boardEvaluator;
     _depth           = depth;
     _branching       = branching;
     _scoreFinalState = scoreFinalState;
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of a search tree.
 /// </summary>
 /// <param name="evaluator">Evaluator to use when evaluating a board position.</param>
 public SearchTree(IBoardEvaluator evaluator)
 {
     m_evaluator          = evaluator;
     m_alphaBetaTable     = new AlphaBetaTable();
     m_quiescentTable     = new QuiescentTable();
     m_captureMoveCompare = new CaptureMoveComparer(m_evaluator);
     m_scoreMoveCompare   = new ScoreMoveComparer(m_evaluator);
 }
コード例 #6
0
 public ChessBot(IBoardEvaluator evaluator, int depth, Color color, bool test)
 {
     Color          = color;
     testMode       = test;
     boardEvaluator = evaluator;
     maxDepth       = depth;
     boardEvalCache = new ConcurrentDictionary <EvalCacheKey, float>();
 }
コード例 #7
0
 public AlphaBeta(int searchDepth)
 {
     this.boardEvaluator  = new StandardBoardEvaluator();
     this.searchDepth     = searchDepth;
     message              = "";
     this.boardsEvaluated = 0;
     this.quiescenceCount = 0;
     this.cutOffsProduced = 0;
 }
コード例 #8
0
ファイル: ConfigManager.cs プロジェクト: Spongie/Chess
        public static void SaveCache(IBoardEvaluator boardEvaluator, ConcurrentDictionary <EvalCacheKey, float> cache, int depth, Color color)
        {
            string directory = $"BotConfigs\\Cache\\";

            CreateDirectoryIfNotExists(directory);

            var cacheList = cache.Select(s => new CacheFileEntry {
                CacheKey = s.Key, Score = s.Value
            }).ToList();

            var xmlSerializer = new XmlSerializer(typeof(List <CacheFileEntry>));

            using (var stream = new FileStream(directory + boardEvaluator.GetBotId(depth) + ".cache", FileMode.Create))
            {
                xmlSerializer.Serialize(stream, cacheList);
            }
            //File.WriteAllText(directory + boardEvaluator.GetBotId(depth) + ".cache", JsonConvert.SerializeObject(cache));
        }
コード例 #9
0
        /// <summary>
        /// Instantiates a new instance of the chess facade.
        /// </summary>
        public ChessFacade()
        {
            m_openingBook              = new OpeningBook();
            m_evaluator                = new BoardEvaluator();
            m_searchTree               = new SearchTree(m_evaluator);
            m_timeControl              = new TimeControl();
            m_engineManager            = new EngineManager(m_openingBook, m_searchTree, m_timeControl);
            m_engineManager.MoveFound += EngineMoveFound;

            m_engineConfiguration = new EngineConfiguration(true, true, new TimeSpan(0, 1, 0), 25);
            m_clockConfiguration  = new ClockConfiguration(ClockType.Conventional, 40, new TimeSpan(0, 25, 0), new TimeSpan(0, 15, 0), new TimeSpan(0, 0, 10));

            m_currentGame = new Game(null, m_clockConfiguration);
            m_currentGame.WhiteClockNotifier += WhiteClockEventHandler;
            m_currentGame.BlackClockNotifier += BlackClockEventHandler;
            m_boardCopy = new Board(m_currentGame.Board);

            m_previousGames   = new Stack <Game>();
            m_subsequentGames = new Stack <Game>();
        }
コード例 #10
0
ファイル: ChessFacade.cs プロジェクト: prezz/Firoz-Chess
        /// <summary>
        /// Instantiates a new instance of the chess facade.
        /// </summary>
        public ChessFacade()
        {
            m_openingBook = new OpeningBook();
              m_evaluator = new BoardEvaluator();
              m_searchTree = new SearchTree(m_evaluator);
              m_timeControl = new TimeControl();
              m_engineManager = new EngineManager(m_openingBook, m_searchTree, m_timeControl);
              m_engineManager.MoveFound += EngineMoveFound;

              m_engineConfiguration = new EngineConfiguration(true, true, new TimeSpan(0, 1, 0), 25);
              m_clockConfiguration = new ClockConfiguration(ClockType.Conventional, 40, new TimeSpan(0, 25, 0), new TimeSpan(0, 15, 0), new TimeSpan(0, 0, 10));

              m_currentGame = new Game(null, m_clockConfiguration);
              m_currentGame.WhiteClockNotifier += WhiteClockEventHandler;
              m_currentGame.BlackClockNotifier += BlackClockEventHandler;
              m_boardCopy = new Board(m_currentGame.Board);

              m_previousGames = new Stack<Game>();
              m_subsequentGames = new Stack<Game>();
        }
コード例 #11
0
 public MonteCarloTreeSearchPlacementExpander(int iterations, IMoveDecisionMaker rolloutMoveMaker, IBoardEvaluator boardEvaluator, int maxChildrenPerPiece) : base(iterations, rolloutMoveMaker)
 {
     MaxChildrenPerPiece = maxChildrenPerPiece;
     BoardEvaluator      = boardEvaluator;
 }
コード例 #12
0
 public MonteCarloTreeSearchMoveMaker(int iterations, IMoveDecisionMaker rolloutMoveMaker, IBoardEvaluator boardEvaluator, int maxChildrenPerPiece)
 {
     _mcts = new MonteCarloTreeSearchPlacementExpander(iterations, rolloutMoveMaker, boardEvaluator, maxChildrenPerPiece);
 }
コード例 #13
0
 public WeightedTreeSearchPreplacer(IBoardEvaluator boardEvaluator, int iterations, int maxBranching)
 {
     _boardEvaluator = boardEvaluator;
     _iterations     = iterations;
     _maxBranching   = maxBranching;
 }
コード例 #14
0
 public SimpleCheckersPlayer(PieceColor color, IBoardEvaluator boardEvaluator)
 {
     this._color = color;
     _boardEvaluator = boardEvaluator;
 }
コード例 #15
0
 public BestEvaluatorStrategy(IBoardEvaluator evaluator)
 {
     _evaluator = evaluator;
 }
コード例 #16
0
 public MiniMax(int searchDepth)
 {
     this.boardEvaluator = new StandardBoardEvaluator();
     this.searchDepth    = searchDepth;
     message             = "";
 }
コード例 #17
0
 /// <summary>
 /// Initializes a new instance of the ScoreMoveComparer.
 /// </summary>
 /// <param name="evaluator"></param>
 public ScoreMoveComparer(IBoardEvaluator evaluator)
 {
     m_captureMoveCompare = new CaptureMoveComparer(evaluator);
 }
コード例 #18
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="board">Board to carry out null move on.</param>
 /// <param name="evaluator">The current board evaluator.</param>
 public NullMove(Board board, IBoardEvaluator evaluator)
 {
     m_board     = board;
     m_evaluator = evaluator;
 }
コード例 #19
0
 /// <summary>
 /// Initializes a new instance of the CaptureMoveComparer.
 /// </summary>
 /// <param name="evaluator"></param>
 public CaptureMoveComparer(IBoardEvaluator evaluator)
 {
     m_evaluator = evaluator;
 }