public override int Apply(byte depth, ISearchTree tree, int alpha, int beta) { if (depth < Depth || !tree.TimeLeft) { return Score; } // If no children, get moves. if (Children == null) { var items = tree.GetMoves(Field, (Depth & 1) == 1); var childDepth = (byte)(Depth + 1); Children = new ISearchTreeNode[7]; var item0 = items[0]; var item1 = items[1]; var item2 = items[2]; var item3 = items[3]; var item4 = items[4]; var item5 = items[5]; var item6 = items[6]; if (item2 != Field.Empty) { Children[Count++] = tree.GetNode(item2, childDepth); } if (item4 != Field.Empty) { Children[Count++] = tree.GetNode(item4, childDepth); } if (item3 != Field.Empty) { Children[Count++] = tree.GetNode(item3, childDepth); } if (item1 != Field.Empty) { Children[Count++] = tree.GetNode(item1, childDepth); } if (item5 != Field.Empty) { Children[Count++] = tree.GetNode(item5, childDepth); } if (item0 != Field.Empty) { Children[Count++] = tree.GetNode(item0, childDepth); } if (item6 != Field.Empty) { Children[Count++] = tree.GetNode(item6, childDepth); } } Score = ApplyChildren(depth, tree, alpha, beta); return Score; }
protected override int ApplyChildren(byte depth, ISearchTree tree, int alpha, int beta) { for (var i = 0; i < Count; i++) { Children[i].Apply(depth, tree, alpha, beta); } // never update this score. return Score; }
/// <summary> /// Instantiates a new instance of the EngineThreadManager. /// </summary> /// <param name="openingBook">Opening book to use. Can be null if no opening book is to be used.</param> /// <param name="searchEvaluator">Search tree with evaluator to use for moves not pressent in the opening book.</param> public EngineThreadManager(IOpeningBook openingBook, ISearchTree searchEvaluator) { m_openingBook = openingBook; m_searchTree = searchEvaluator; m_waitHandle = new ManualResetEvent(true); m_workerThread = new BackgroundWorker(); m_workerThread.DoWork += FindMove; m_workerThread.RunWorkerCompleted += FindMoveCompleted; }
public ConvexHullHalf(TPoint2D shortcutStart, bool upper, ISearchTree <TPoint2D> points) { IsUpper = upper; ShortcutStart = shortcutStart; if (points != null) { Points = points; InitializePoints(); } }
public ProbabilityLimitedExpectiMaxer(ISearchTree searchTree, double minProbability = 0.004, int maxSearchDepth = 6) { this.searchTree = searchTree; this.minProbability = minProbability; this.maxSearchDepth = maxSearchDepth; this.searchStatistics = new SearchStatistics { RootNodeGrandchildren = this.searchTree.RootNode.Children.Values.Sum(c => c.Children.Count()) }; }
/// <summary> /// Constructs a TestEntity instance. /// </summary> /// <param name="startPosition">The initial position of the test entity.</param> /// <param name="size">The size of the test entity.</param> /// <param name="entities">The map content manager that stores the entities.</param> public TestEntity(RCNumVector startPosition, RCNumVector size, ISearchTree <TestEntity> entities) { this.currentPosition = startPosition; this.size = size; this.currentSpeed = 0; this.goal = this.currentPosition; this.currentDirection = MapDirection.North; this.admissableVelocities = new List <Tuple <RCNumber, MapDirection> >(); this.selectedVelocity = null; this.entities = entities; }
public override int Apply(byte depth, ISearchTree tree, int alpha, int beta) { Score = base.Apply(depth, tree, alpha, beta); // We want to know more. if (!m_IsWinning) { Score += m_Value; } return Score; }
/// <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>(); }
protected override int ApplyChildren(byte depth, ISearchTree tree, int alpha, int beta) { Score = Scores.YelWins[Depth]; var i = 0; var count = Count - 1; for (/**/; i <= count; i++) { var child = Children[i]; var test = child.Apply(depth, tree, alpha, beta); if (test > Score) { Score = test; if (Score > alpha) { alpha = Score; } } else if (beta <= alpha) { break; } } if (i > count) { i = count; } for (/**/; i >= 0; i--) { var val = Children[i].Score; for (var swap = i + 1; swap <= count; swap++) { var other = Children[swap]; if (val >= other.Score) { break; } Children[swap] = Children[swap - 1]; Children[swap - 1] = other; } } return Score; }
public int Apply(byte depth, ISearchTree tree, int alpha, int beta) { return Score; }
public NoSearchAgent(string expression, ISearchTree searchTree) : base(expression, searchTree) { }
protected abstract int ApplyChildren(byte depth, ISearchTree tree, int alpha, int beta);
public ISearcher Build(ISearchTree searchTree) { return(new ProbabilityLimitedExpectiMaxer(searchTree)); }
public RecursiveBranchAgent(string expression, ISearchTree searchTree) : base(expression, searchTree) { }
public Search(ISearchTree searchTree) { _searchTree = searchTree; }
public TypeDefinitionCheckingContext(TypeDefinition typeToCheck, TypeDefinitionCheckingResult.SearchType searchType, ISearchTree searchTree, bool serachForDependencyInFieldConstant = false) { _typeToCheck = typeToCheck; _result = new TypeDefinitionCheckingResult(searchType, searchTree); _serachForDependencyInFieldConstant = serachForDependencyInFieldConstant; }
public TypeDefinitionCheckingContext(TypeDefinition typeToCheck, TypeDefinitionCheckingResult.SearchType searchType, ISearchTree searchTree) { _typeToCheck = typeToCheck; _result = new TypeDefinitionCheckingResult(searchType, searchTree); }
public abstract int Apply(byte depth, ISearchTree tree, int alpha, int beta);
public TypeDefinitionCheckingResult(SearchType searchType, ISearchTree searchTree) { _searchType = searchType; _searchTree = searchTree; _hasDependencyFromOutsideOfSearchTree = false; }
protected SearchAgent(string expression, ISearchTree searchTree) { Expression = expression; SearchTree = searchTree; }
public ISearcher Build(ISearchTree searchTree) { return new ProbabilityLimitedExpectiMaxer(searchTree); }