private int CountRoadLengthFromIntersection(int playerID, Intersection curInt, HashSet<Edge> visited, HashSet<Edge> globalVisited)
{
// check for break
Piece curPiece = GetPiece(curInt);
if(curPiece != null && curPiece.Player != playerID) return 0; // no more edges this direction
// find connections
var edgesOut = GetAdjacentEdges(curInt).Where(e => !visited.Contains(e) && GetRoad(e) == playerID).ToArray(); // temp array
int highest = 0;
foreach (var edge in edgesOut)
{
// add edges to visited
visited.Add(edge);
globalVisited.Add(edge);
Intersection otherEnd = GetAdjacentIntersections(edge).First(i => !i.Equals(curInt));
int depthSearch = CountRoadLengthFromIntersection(playerID, otherEnd, visited, globalVisited);
if (1 + depthSearch > highest) highest = 1 + depthSearch;
visited.Remove(edge);
}
return highest;
}