Fixes issue #2
This commit is contained in:
parent
ae2c6c321f
commit
526d15f2c7
3 changed files with 40 additions and 14 deletions
|
|
@ -8,6 +8,7 @@ import java.awt.*;
|
|||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Diese Klasse representiert das Spielfeld. Sie beinhaltet das Hintergrundbild, welches mit Perlin noise erzeugt wurde,
|
||||
|
|
@ -153,15 +154,30 @@ public class GameMap {
|
|||
private void generateEdges() {
|
||||
|
||||
List<Node<Castle>> castleNodes = castleGraph.getNodes();
|
||||
|
||||
/*
|
||||
for (int i = 0; i < castleNodes.size(); i++) {
|
||||
if (i == castleNodes.size() - 1)
|
||||
castleGraph.addEdge(castleNodes.get(i), castleNodes.get(0));
|
||||
else
|
||||
castleGraph.addEdge(castleNodes.get(i), castleNodes.get(i+1));
|
||||
}*/
|
||||
|
||||
final double radius = 300.0;
|
||||
|
||||
for (Node<Castle> cast : castleNodes) {
|
||||
for (Node<Castle> c : allCastlesInRadius(cast, castleNodes, radius))
|
||||
castleGraph.addEdge(cast, c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private List<Node<Castle>> allCastlesInRadius(Node<Castle> castle, List<Node<Castle>> allCastles, double r) {
|
||||
|
||||
return allCastles.stream()
|
||||
.filter(x -> x.getValue().distance(castle.getValue()) <= r)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Hier werden die Burgen in Königreiche unterteilt. Dazu wird der {@link Clustering} Algorithmus aufgerufen.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue