コード例 #1
0
		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;
		}
コード例 #2
0
		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;
		}
コード例 #3
0
        /// <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;
        }
コード例 #4
0
 public ConvexHullHalf(TPoint2D shortcutStart, bool upper, ISearchTree <TPoint2D> points)
 {
     IsUpper       = upper;
     ShortcutStart = shortcutStart;
     if (points != null)
     {
         Points = points;
         InitializePoints();
     }
 }
コード例 #5
0
        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())
            };
        }
コード例 #6
0
ファイル: TestEntity.cs プロジェクト: kovacsgabor55/marsara
 /// <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;
 }
コード例 #7
0
		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;
		}
コード例 #8
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>();
        }
コード例 #9
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>();
        }
コード例 #10
0
		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;
		}
コード例 #11
0
		public int Apply(byte depth, ISearchTree tree, int alpha, int beta) { return Score; }
コード例 #12
0
 public NoSearchAgent(string expression, ISearchTree searchTree) : base(expression, searchTree)
 {
 }
コード例 #13
0
		protected abstract int ApplyChildren(byte depth, ISearchTree tree, int alpha, int beta);
コード例 #14
0
 public ISearcher Build(ISearchTree searchTree)
 {
     return(new ProbabilityLimitedExpectiMaxer(searchTree));
 }
コード例 #15
0
 public RecursiveBranchAgent(string expression, ISearchTree searchTree) : base(expression, searchTree)
 {
 }
コード例 #16
0
ファイル: Search.cs プロジェクト: atzedent/globkit
 public Search(ISearchTree searchTree)
 {
     _searchTree = searchTree;
 }
コード例 #17
0
 public TypeDefinitionCheckingContext(TypeDefinition typeToCheck, TypeDefinitionCheckingResult.SearchType searchType, ISearchTree searchTree, bool serachForDependencyInFieldConstant = false)
 {
     _typeToCheck = typeToCheck;
     _result      = new TypeDefinitionCheckingResult(searchType, searchTree);
     _serachForDependencyInFieldConstant = serachForDependencyInFieldConstant;
 }
コード例 #18
0
 public TypeDefinitionCheckingContext(TypeDefinition typeToCheck, TypeDefinitionCheckingResult.SearchType searchType, ISearchTree searchTree)
 {
     _typeToCheck = typeToCheck;
     _result      = new TypeDefinitionCheckingResult(searchType, searchTree);
 }
コード例 #19
0
		public abstract int Apply(byte depth, ISearchTree tree, int alpha, int beta);
コード例 #20
0
        /// <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;
        }
コード例 #21
0
 public TypeDefinitionCheckingResult(SearchType searchType, ISearchTree searchTree)
 {
     _searchType = searchType;
     _searchTree = searchTree;
     _hasDependencyFromOutsideOfSearchTree = false;
 }
コード例 #22
0
 protected SearchAgent(string expression, ISearchTree searchTree)
 {
     Expression = expression;
     SearchTree = searchTree;
 }
コード例 #23
0
 public ISearcher Build(ISearchTree searchTree)
 {
     return new ProbabilityLimitedExpectiMaxer(searchTree);
 }