private void findEndClusters(Node start, Node end, out Cluster startCluster, out Cluster endCluster) { startCluster = null; endCluster = null; foreach (var cluster in clusterMap.getClusterMap()) { if (cluster.inBounds(start)) startCluster = cluster; if (cluster.inBounds(end)) endCluster = cluster; if (startCluster != null && endCluster != null) break; //both have been found } }
private void generateExits(ClusterMap clusterMap) { var clusters = clusterMap.getClusterMap(); for (int x = 0; x < clusters.GetLength(0); ++x) { for (int y = 0; y < clusters.GetLength(1); ++y) { if (y >= 1) { var cluster1 = clusters[x, y]; var cluster2 = clusters[x, y - 1]; makeExitHorizontal(cluster1, cluster2, clusterMap, 1); makeMiddleExitHorizontal(cluster1, cluster2, clusterMap); makeExitHorizontal(cluster1, cluster2, clusterMap, -1); } if (x >= 1) { var cluster1 = clusters[x, y]; var cluster2 = clusters[x - 1, y]; makeExitVertical(cluster1, cluster2, clusterMap, 1); makeMiddleExitVertical(cluster1, cluster2, clusterMap); makeExitVertical(cluster1, cluster2, clusterMap, -1); } } } }
private void makePathsBetweenExits(ClusterMap clusterMap) { var clusters = clusterMap.getClusterMap(); var threads = new List <Thread>(); Stopwatch sw = new Stopwatch(); sw.Start(); foreach (Cluster cluster in clusters) { Thread thread = new Thread(connectExitStarter); thread.Start(cluster); } foreach (var t in threads) { t.Join(); } bool lives = false; foreach (var t in threads) { if (t.IsAlive) { lives = true; } } Out.put("active threads connecting exits: " + lives); Out.put("connecting exits took " + sw.ElapsedMilliseconds + "ms"); sw.Stop(); }