public SimpleMoveEstimator(GameSetting setting, IBoardEvaluator boardEvaluator, IMoveNominator moveNominator, int maxDepth) { this.Setting = setting; this.boardEvaluator = boardEvaluator; this.moveNominator = moveNominator; this.maxDepth = maxDepth; }
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")); }
public ChessBot(IBoardEvaluator evaluator, int depth, Color color) { Color = color; boardEvaluator = evaluator; maxDepth = depth; boardEvalCache = new ConcurrentDictionary <EvalCacheKey, float>(ConfigManager.LoadCache(boardEvaluator, maxDepth, Color)); }
public EvaluatorTreeSearchPreplacer(IBoardEvaluator boardEvaluator, int depth, int branching, bool scoreFinalState) { _boardEvaluator = boardEvaluator; _depth = depth; _branching = branching; _scoreFinalState = scoreFinalState; }
/// <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); }
public ChessBot(IBoardEvaluator evaluator, int depth, Color color, bool test) { Color = color; testMode = test; boardEvaluator = evaluator; maxDepth = depth; boardEvalCache = new ConcurrentDictionary <EvalCacheKey, float>(); }
public AlphaBeta(int searchDepth) { this.boardEvaluator = new StandardBoardEvaluator(); this.searchDepth = searchDepth; message = ""; this.boardsEvaluated = 0; this.quiescenceCount = 0; this.cutOffsProduced = 0; }
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)); }
/// <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>(); }
/// <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>(); }
public MonteCarloTreeSearchPlacementExpander(int iterations, IMoveDecisionMaker rolloutMoveMaker, IBoardEvaluator boardEvaluator, int maxChildrenPerPiece) : base(iterations, rolloutMoveMaker) { MaxChildrenPerPiece = maxChildrenPerPiece; BoardEvaluator = boardEvaluator; }
public MonteCarloTreeSearchMoveMaker(int iterations, IMoveDecisionMaker rolloutMoveMaker, IBoardEvaluator boardEvaluator, int maxChildrenPerPiece) { _mcts = new MonteCarloTreeSearchPlacementExpander(iterations, rolloutMoveMaker, boardEvaluator, maxChildrenPerPiece); }
public WeightedTreeSearchPreplacer(IBoardEvaluator boardEvaluator, int iterations, int maxBranching) { _boardEvaluator = boardEvaluator; _iterations = iterations; _maxBranching = maxBranching; }
public SimpleCheckersPlayer(PieceColor color, IBoardEvaluator boardEvaluator) { this._color = color; _boardEvaluator = boardEvaluator; }
public BestEvaluatorStrategy(IBoardEvaluator evaluator) { _evaluator = evaluator; }
public MiniMax(int searchDepth) { this.boardEvaluator = new StandardBoardEvaluator(); this.searchDepth = searchDepth; message = ""; }
/// <summary> /// Initializes a new instance of the ScoreMoveComparer. /// </summary> /// <param name="evaluator"></param> public ScoreMoveComparer(IBoardEvaluator evaluator) { m_captureMoveCompare = new CaptureMoveComparer(evaluator); }
/// <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; }
/// <summary> /// Initializes a new instance of the CaptureMoveComparer. /// </summary> /// <param name="evaluator"></param> public CaptureMoveComparer(IBoardEvaluator evaluator) { m_evaluator = evaluator; }