public List <PointField> doUpdate(bool oneloop = false) { var returnList = new List <PointField>(); while (newEntries.Count > 0) { currentlyChecking = newEntries.Dequeue(); var pointList = getConnectedItems(currentlyChecking); if (pointList.Count > 1) { var RouteList = handleListOfConnectedPoints(pointList); returnList.AddRange(from nodeList in RouteList where nodeList.Count >= 4 select findClosed(nodeList) into field where field != null select field); } currentField[currentlyChecking.y, currentlyChecking.x] = currentlyChecking.value; } return(returnList); }
private List <Point> getConnectedItems(GametileUpdate update) { List <Point> list = new List <Point>(); int x = update.x; int y = update.y; if (this.diagonal) { if (this[y - 1, x - 1] && this.currentField[y - 1, x - 1] == update.value) { list.Add(new Point(x - 1, y - 1)); } if (this[y - 1, x + 1] && this.currentField[y - 1, x + 1] == update.value) { list.Add(new Point(x + 1, y - 1)); } if (this[y + 1, x - 1] && this.currentField[y + 1, x - 1] == update.value) { list.Add(new Point(x - 1, y + 1)); } if (this[y + 1, x + 1] && this.currentField[y + 1, x + 1] == update.value) { list.Add(new Point(x + 1, y + 1)); } } if (this[y - 1, x] && this.currentField[y - 1, x] == update.value) { list.Add(new Point(x, y - 1)); } if (this[y + 1, x] && this.currentField[y + 1, x] == update.value) { list.Add(new Point(x, y + 1)); } if (this[y, x - 1] && this.currentField[y, x - 1] == update.value) { list.Add(new Point(x - 1, y)); } if (this[y, x + 1] && this.currentField[y, x + 1] == update.value) { list.Add(new Point(x + 1, y)); } return(list); }
public List <PointField> DoUpdate(bool oneloop = false) { List <PointField> list = new List <PointField>(); while (_newEntries.Count > 0) { _currentlyChecking = _newEntries.Dequeue(); List <Point> connectedItems = GetConnectedItems(_currentlyChecking); if (connectedItems.Count > 1) { IEnumerable <LinkedList <AStarSolver <GameField> .XPathNode> > list2 = HandleListOfConnectedPoints(connectedItems, _currentlyChecking); list.AddRange(list2.Where(current => current.Count >= 4).Select(FindClosed).Where(pointField => true)); } _currentField[_currentlyChecking.Y, _currentlyChecking.X] = _currentlyChecking.Value; } return(list); }
private IEnumerable <LinkedList <AStarSolver <GameField> .XPathNode> > HandleListOfConnectedPoints( List <Point> pointList, GametileUpdate update) { List <LinkedList <AStarSolver <GameField> .XPathNode> > list = new List <LinkedList <AStarSolver <GameField> .XPathNode> >(); int num = 0; foreach (Point current in pointList) { num++; if (num == pointList.Count / 2 + 1) { return(list); } list.AddRange( pointList.Where(current2 => !(current == current2)) .Select(current2 => _astarSolver.Search(current2, current)) .Where(linkedList => linkedList != null)); } return(list); }
public IEnumerable <PointField> DoUpdate() { var returnList = new List <PointField>(); while (_newEntries.Count > 0) { _currentlyChecking = _newEntries.Dequeue(); var pointList = GetConnectedItems(_currentlyChecking); if (pointList == null) { return(null); } if (pointList.Count > 1) { var routeList = HandleListOfConnectedPoints(pointList); returnList.AddRange(from nodeList in routeList where nodeList.Count >= 4 select FindClosed(nodeList) into field where field != null select field); } _currentField[_currentlyChecking.Y, _currentlyChecking.X] = _currentlyChecking.Value; } return(returnList); }
private List <LinkedList <AStarSolver <GameField> .PathNode> > handleListOfConnectedPoints(List <Point> pointList, GametileUpdate update) { List <LinkedList <AStarSolver <GameField> .PathNode> > list = new List <LinkedList <AStarSolver <GameField> .PathNode> >(); int num = 0; foreach (Point inStartNode in pointList) { ++num; if (num == pointList.Count / 2 + 1) { return(list); } foreach (Point inEndNode in pointList) { if (!(inStartNode == inEndNode)) { LinkedList <AStarSolver <GameField> .PathNode> linkedList = this.astarSolver.Search(inEndNode, inStartNode); if (linkedList != null) { list.Add(linkedList); } } } } return(list); }
private List <LinkedList <AStarSolver <GameField> .PathNode> > handleListOfConnectedPoints(List <Point> pointList, GametileUpdate update) { List <LinkedList <AStarSolver <GameField> .PathNode> > returnList = new List <LinkedList <AStarSolver <GameField> .PathNode> >(); int amount = 0; foreach (Point begin in pointList) { amount++; if (amount == pointList.Count / 2 + 1) { return(returnList); } foreach (Point end in pointList) { if (begin == end) { continue; } LinkedList <AStarSolver <GameField> .PathNode> list = astarSolver.Search(end, begin); if (list != null) { returnList.Add(list); } } } return(returnList); }
private List <LinkedList <AStarSolver <GameField> .PathNode> > handleListOfConnectedPoints(List <Point> pointList, GametileUpdate update) { List <LinkedList <AStarSolver <GameField> .PathNode> > list = new List <LinkedList <AStarSolver <GameField> .PathNode> >(); int num = 0; checked { foreach (Point current in pointList) { num++; if (num == pointList.Count / 2 + 1) { return(list); } foreach (Point current2 in pointList) { if (!(current == current2)) { LinkedList <AStarSolver <GameField> .PathNode> linkedList = this.astarSolver.Search(current2, current); if (linkedList != null) { list.Add(linkedList); } } } } return(list); } }