working on city roads IP

This commit is contained in:
veniti 2019-09-09 19:17:29 +02:00
parent 56690bbb75
commit 3e9b5343f0

View File

@ -26,7 +26,7 @@ namespace Assets.Scripts
public int GetHashCode(Point obj) public int GetHashCode(Point obj)
{ {
return obj.GetHashCode(); return 0;
} }
} }
@ -66,7 +66,7 @@ namespace Assets.Scripts
public void CreateRoadGraph(IList<Point> points) public void CreateRoadGraph(IList<Point> points)
{ {
VoronoiGenerator generator = new VoronoiGenerator(sitesList.SelectMany(site => site.Vertices.Select(i => points[i]).Append(site.Point)).Distinct(new PointProximityComparer(4)).ToList()); VoronoiGenerator generator = new VoronoiGenerator(sitesList.SelectMany(site => site.Vertices.Select(i => points[i]).Append(site.Point)).Distinct(new PointProximityComparer(2)).ToList());
generator.Generate(); generator.Generate();
roads = generator.Delaunay.Morph(s => s.Point, e => Point.Dist(generator.Delaunay.Vertices[e.Item1].Point, generator.Delaunay.Vertices[e.Item2].Point)); roads = generator.Delaunay.Morph(s => s.Point, e => Point.Dist(generator.Delaunay.Vertices[e.Item1].Point, generator.Delaunay.Vertices[e.Item2].Point));
@ -162,7 +162,7 @@ namespace Assets.Scripts
//3.Repeat step#2 until there are (V-1) edges in the spanning tree. //3.Repeat step#2 until there are (V-1) edges in the spanning tree.
graph.Edges = graph.Edges.OrderBy(e => graph.GetEdgeData(e)); graph.Edges = graph.Edges.OrderBy(e => graph.GetEdgeData(e));
graph._edgeData = graph._edgeData.OrderBy(e => e.Value).ToDictionary(e => e.Key, k => k.Value); graph._edgeData = graph._edgeData.OrderByDescending(e => e.Value).ToDictionary(e => e.Key, k => k.Value);
Graph<Point> spanningTree = new Graph<Point>(); Graph<Point> spanningTree = new Graph<Point>();
spanningTree.Vertices = graph.Vertices; spanningTree.Vertices = graph.Vertices;
@ -320,8 +320,8 @@ namespace Assets.Scripts
if (debug.displayCityMainRoads) if (debug.displayCityMainRoads)
{ {
Gizmos.color = new Color(2.54f, 0.127f, 1.56f); //Gizmos.color = new Color(2.54f, 0.127f, 1.56f);
//Gizmos.color = Color.green; Gizmos.color = Color.green;
foreach (var city in cities) foreach (var city in cities)
{ {
DisplayGraphEdges(city.mainRoad); DisplayGraphEdges(city.mainRoad);