private void ExpandFrontier( IHexCell center, IEnumerable <IHexCell> availableCells, PriorityQueue <IHexCell> searchFrontier, IEnumerable <IHexCell> acceptedCells, IHexCell seed, CrawlingWeightFunction weightFunction ) { foreach (var neighbor in Grid.GetNeighbors(center)) { if (availableCells.Contains(neighbor) && !searchFrontier.Contains(neighbor)) { int candidateWeight = weightFunction(neighbor, seed, acceptedCells); if (candidateWeight >= 0) { searchFrontier.Add(neighbor, candidateWeight); } } } }
public IEnumerator <IHexCell> GetCrawlingEnumerator( IHexCell seed, IEnumerable <IHexCell> availableCells, IEnumerable <IHexCell> acceptedCells, CrawlingWeightFunction weightFunction ) { var searchFrontier = new PriorityQueue <IHexCell>(); searchFrontier.Add(seed, 0); while (searchFrontier.Count() > 0) { IHexCell current = searchFrontier.DeleteMin(); if (availableCells.Contains(current)) { yield return(current); ExpandFrontier(current, availableCells, searchFrontier, acceptedCells, seed, weightFunction); } } }