Skip to content

Commit 61aca49

Browse files
Updates to spawnPlacer for LastTerrain's and fixes to symmtry lines. (#474)
* Change the team separation for spawn last * altered spawnPlacer strategy * update call to drawSymmetryLines * increase mapsize for Inequality unit tests
1 parent 954a013 commit 61aca49

File tree

5 files changed

+27
-13
lines changed

5 files changed

+27
-13
lines changed

generator/src/main/java/com/faforever/neroxis/generator/terrain/FractalNoiseLastTerrainGenerator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void initialize(SCMap map, long seed, GeneratorParameters generatorParame
5252
waterHeight -= fractalParams.waterHeight();
5353

5454
symmetryLines.setSize(map.getSize() + 1);
55-
symmetryLines.drawSymmetryLines();
55+
symmetryLines.drawSymmetryLines(symmetrySettings.terrainSymmetry());
5656
}
5757

5858
@Override
@@ -138,7 +138,7 @@ protected void setupHeightmapPipeline() {
138138

139139

140140
// Blur and add mountains along the line of symmetry
141-
if (Set.of(Symmetry.QUAD, Symmetry.DIAG, Symmetry.POINT2, Symmetry.POINT3, Symmetry.POINT4, Symmetry.POINT5,
141+
if (Set.of(Symmetry.POINT2, Symmetry.POINT3, Symmetry.POINT4, Symmetry.POINT5,
142142
Symmetry.POINT6, Symmetry.POINT7, Symmetry.POINT8, Symmetry.POINT9, Symmetry.POINT10,
143143
Symmetry.POINT11, Symmetry.POINT12, Symmetry.POINT13, Symmetry.POINT14, Symmetry.POINT15,
144144
Symmetry.POINT16).contains(symmetrySettings.terrainSymmetry())

generator/src/main/java/com/faforever/neroxis/generator/terrain/MultiLevelLastTerrainGenerator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,15 @@ private void addWaterAreasToNoiseMap(int mapSize) {
121121
switch (waterMask) {
122122
case WaterMasks.SYMMETRY_LINE:
123123
// Water will be more likely along the symmetry line(s), kinda splitting the map in half, or pie slices for odd symmetries
124-
waterArea.drawSymmetryLines();
124+
waterArea.drawSymmetryLines(symmetrySettings.terrainSymmetry());
125125
waterArea.inflate(
126126
StrictMath.min(256, mapSize / 4f / symmetrySettings.teamSymmetry().getNumSymPoints()));
127127
waterAreaBlur = waterArea.copyAsFloatMask(0f, 1f);
128128
waterAreaBlur.blur(mapSize / 4);
129129
break;
130130
case WaterMasks.HOUR_GLASS:
131131
// An unusual shape, which increase the likelihood of water along the symmetry lines and the corners of the map
132-
waterArea.drawSymmetryLines();
132+
waterArea.drawSymmetryLines(symmetrySettings.terrainSymmetry());
133133
waterArea.inflate(mapSize / 4f / symmetrySettings.teamSymmetry().getNumSymPoints());
134134
List<Vector2> symmetryPoints = waterArea.getSymmetryPointsWithOutOfBounds(new Vector2(0, 0),
135135
SymmetryType.SPAWN)

generator/src/test/java/com/faforever/neroxis/generator/MapGeneratorTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,15 @@ public void TestEqualityTournamentStyle() throws IOException {
204204
@Test
205205
public void TestInequalityTournamentStyle() throws Exception {
206206
MapGenerator instance1 = new MapGenerator(true);
207-
new CommandLine(instance1).execute("--tournament-style", "--map-size", "256", "--spawn-count", "2");
207+
new CommandLine(instance1).execute("--tournament-style", "--map-size", "512", "--spawn-count", "2");
208208
SCMap map1 = instance1.getMap();
209209
long generationTime1 = instance1.getGenerationTime();
210210
long seed1 = instance1.getBasicOptions().getSeed();
211211

212212
Thread.sleep(1000);
213213
MapGenerator instance2 = new MapGenerator(true);
214214

215-
new CommandLine(instance2).execute("--tournament-style", "--seed", String.valueOf(seed1), "--map-size", "256",
215+
new CommandLine(instance2).execute("--tournament-style", "--seed", String.valueOf(seed1), "--map-size", "512",
216216
"--spawn-count", "2");
217217
SCMap map2 = instance2.getMap();
218218
long generationTime2 = instance2.getGenerationTime();
@@ -268,15 +268,15 @@ public void TestEqualityBlind() throws IOException {
268268
@Test
269269
public void TestInequalityBlind() throws Exception {
270270
MapGenerator instance1 = new MapGenerator(true);
271-
new CommandLine(instance1).execute("--blind", "--map-size", "256", "--spawn-count", "2");
271+
new CommandLine(instance1).execute("--blind", "--map-size", "512", "--spawn-count", "2");
272272
SCMap map1 = instance1.getMap();
273273
long generationTime1 = instance1.getGenerationTime();
274274
long seed1 = instance1.getBasicOptions().getSeed();
275275

276276
Thread.sleep(1000);
277277
MapGenerator instance2 = new MapGenerator(true);
278278

279-
new CommandLine(instance2).execute("--blind", "--seed", String.valueOf(seed1), "--map-size", "256",
279+
new CommandLine(instance2).execute("--blind", "--seed", String.valueOf(seed1), "--map-size", "512",
280280
"--spawn-count", "2");
281281
SCMap map2 = instance2.getMap();
282282
long generationTime2 = instance2.getGenerationTime();
@@ -331,15 +331,15 @@ public void TestEqualityUnexplored() throws IOException {
331331
@Test
332332
public void TestInequalityUnexplored() throws Exception {
333333
MapGenerator instance1 = new MapGenerator(true);
334-
new CommandLine(instance1).execute("--unexplored", "--map-size", "256", "--spawn-count", "2");
334+
new CommandLine(instance1).execute("--unexplored", "--map-size", "512", "--spawn-count", "2");
335335
SCMap map1 = instance1.getMap();
336336
long generationTime1 = instance1.getGenerationTime();
337337
long seed1 = instance1.getBasicOptions().getSeed();
338338

339339
Thread.sleep(1000);
340340
MapGenerator instance2 = new MapGenerator(true);
341341

342-
new CommandLine(instance2).execute("--unexplored", "--seed", String.valueOf(seed1), "--map-size", "256",
342+
new CommandLine(instance2).execute("--unexplored", "--seed", String.valueOf(seed1), "--map-size", "512",
343343
"--spawn-count", "2");
344344
SCMap map2 = instance2.getMap();
345345
long generationTime2 = instance2.getGenerationTime();

shared/src/main/java/com/faforever/neroxis/map/placement/SpawnPlacer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ private boolean tryPlaceSpawns(int spawnCount, BooleanMask spawnMask, float team
8484
BooleanMask spawnMaskCopy = spawnMask.copy();
8585
spawnMaskCopy.fillSides(map.getSize() / spawnCount * 3 / 2, false)
8686
.fillCenter(teamSeparation, false)
87+
.subtract(
88+
new BooleanMask(map.getSize() + 1, random.nextLong(), spawnMask.getSymmetrySettings())
89+
.drawSymmetryLines(spawnMask.getSymmetrySettings().teamSymmetry())
90+
.inflate((float) teamSeparation / spawnMask.getSymmetrySettings()
91+
.spawnSymmetry()
92+
.getNumSymPoints()))
8793
.fillEdge(map.getSize() / 32, false)
8894
.limitToSymmetryRegion();
8995
Vector2 location = spawnMaskCopy.getRandomPosition();

shared/src/main/java/com/faforever/neroxis/mask/BooleanMask.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ private void drawLine(int x0, int y0, int x1, int y1) {
800800
}
801801
}
802802

803-
public BooleanMask drawSymmetryLines() {
803+
public BooleanMask drawSymmetryLines(Symmetry symmetry) {
804804
return enqueue(() -> {
805805
int mapSize = getSize();
806806
int halfX = mapSize + 1 >> 1;
@@ -813,12 +813,20 @@ public BooleanMask drawSymmetryLines() {
813813
drawLine(halfX, halfY, (int) rotated.x(), (int) rotated.y());
814814
}
815815
} else {
816-
switch (symmetrySettings.terrainSymmetry()) {
817-
case QUAD, Z, DIAG, POINT2, POINT4, POINT6, POINT8, POINT10, POINT12, POINT14, POINT16 ->
816+
switch (symmetry) {
817+
case Z, POINT2, POINT4, POINT6, POINT8, POINT10, POINT12, POINT14, POINT16 ->
818818
drawLine(0, halfY, mapSize, halfY);
819819
case X -> drawLine(halfX, 0, halfX, mapSize);
820820
case XZ -> drawLine(0, 0, mapSize, mapSize);
821821
case ZX -> drawLine(0, mapSize, mapSize, 0);
822+
case QUAD -> {
823+
drawLine(0, halfY, mapSize, halfY);
824+
drawLine(halfX, 0, halfX, mapSize);
825+
}
826+
case DIAG -> {
827+
drawLine(0, 0, mapSize, mapSize);
828+
drawLine(0, mapSize, mapSize, 0);
829+
}
822830
case POINT3, POINT5, POINT7, POINT9, POINT11, POINT13, POINT15 -> {
823831
for (int slice = 0; slice < numSymPoints; slice++) {
824832
Vector2 rotated = SymmetryUtil.getRotatedPoint(-mapSize, halfY, mapSize,

0 commit comments

Comments
 (0)