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); }
public void OnEnter(ITree <TNode> node, ITreeSearchContinuation treeSearchContinuation) { _depthCounter.OnEnter(node, treeSearchContinuation); if (_depthCounter.CurrentDepth >= _maxDepth) { treeSearchContinuation.DontEnterChildren(); } }
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(); } }
public void OnEnter(ITree <int> node, ITreeSearchContinuation treeSearchContinuation) { if (ShouldStop(node.Node)) { treeSearchContinuation.Stop(); } if (ShouldNotEnterChildren(node.Node)) { treeSearchContinuation.DontEnterChildren(); } _nested.Add(node.Node); }
public void OnEnter(ITree <JumpNode> node, ITreeSearchContinuation treeSearchContinuation) { int actualValue = CountActualValue(node.Node); if (actualValue == _targetBorder.LooseValue) { treeSearchContinuation.DontEnterChildren(); } else { MaxValueUpdated(actualValue, treeSearchContinuation, node); } }