Exemplo n.º 1
0
        private bool CuttoffToBestPosition(ITreeSearchContinuation treeSearchContinuation, int targetRowIndex, Field whiteField)
        {
            if (_targetBorder.IsLeftCloserThanRigth(targetRowIndex, whiteField.RowIndex))
            {
                var minRow             = Math.Min(targetRowIndex, whiteField.RowIndex);
                var maxRow             = Math.Max(targetRowIndex, whiteField.RowIndex);
                int blackFieldsForJump = 0;
                int nulifyOddDistance  = (maxRow - minRow + 1) % 2;
                if (targetRowIndex < whiteField.RowIndex)
                {
                    blackFieldsForJump = CountBlackFieldsBetween(minRow + nulifyOddDistance, maxRow - 1);
                }
                else
                {
                    blackFieldsForJump = CountBlackFieldsBetween(minRow + 1, maxRow - nulifyOddDistance);
                }

                var mininmalRequired = (maxRow - minRow - 1) / 2 + 1;
                if (mininmalRequired > blackFieldsForJump)
                {
                    treeSearchContinuation.DontEnterChildren();
                    CuttoffsCount++;
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
 public void OnEnter(ITree <TNode> node, ITreeSearchContinuation treeSearchContinuation)
 {
     _depthCounter.OnEnter(node, treeSearchContinuation);
     if (_depthCounter.CurrentDepth >= _maxDepth)
     {
         treeSearchContinuation.DontEnterChildren();
     }
 }
Exemplo n.º 3
0
 public override void OnEnter(ITree <int> node, ITreeSearchContinuation treeSearchContinuation)
 {
     base.OnEnter(node, treeSearchContinuation);
     if (node.Node == STOP_ON_THIS)
     {
         treeSearchContinuation.Stop();
     }
     if (node.Node == DONT_ENTER_CHILDREN)
     {
         treeSearchContinuation.DontEnterChildren();
     }
 }
Exemplo n.º 4
0
 public void OnEnter(ITree <int> node, ITreeSearchContinuation treeSearchContinuation)
 {
     if (ShouldStop(node.Node))
     {
         treeSearchContinuation.Stop();
     }
     if (ShouldNotEnterChildren(node.Node))
     {
         treeSearchContinuation.DontEnterChildren();
     }
     _nested.Add(node.Node);
 }
Exemplo n.º 5
0
        public void OnEnter(ITree <JumpNode> node, ITreeSearchContinuation treeSearchContinuation)
        {
            int actualValue = CountActualValue(node.Node);

            if (actualValue == _targetBorder.LooseValue)
            {
                treeSearchContinuation.DontEnterChildren();
            }
            else
            {
                MaxValueUpdated(actualValue, treeSearchContinuation, node);
            }
        }