MapGenerator (#34)
This generate maps following a simple structure First we choose map size depending on the difficulty we grind the edge with a random pattern so the map is not just a square we pick a random open piece and try to make a piece out of it between a size of 1 to 3 and we do this in a loop until all open spaces are filled this is not the best but it's efficient known problem: - We can have sometime a lot of small pieces - We can have weird shape, for instance pieces that are only connected by corner I think this is technically not a problem in the end. but this could be changed Co-authored-by: Debucquoy <debucqquoy.anthony@gmail.com> Reviewed-on: #34 Reviewed-by: Mat_02 <diletomatteo@gmail.com>
This commit is contained in:
26
app/src/test/java/school_project/MapGeneratorTest.java
Normal file
26
app/src/test/java/school_project/MapGeneratorTest.java
Normal file
@ -0,0 +1,26 @@
|
||||
package school_project;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class MapGeneratorTest {
|
||||
|
||||
@Test
|
||||
void generate() {
|
||||
Map[] maps = new Map[] {
|
||||
MapGenerator.generate(MapGenerator.Difficulty.Easy),
|
||||
MapGenerator.generate(MapGenerator.Difficulty.Medium),
|
||||
MapGenerator.generate(MapGenerator.Difficulty.Difficult),
|
||||
};
|
||||
|
||||
for(Map m: maps){
|
||||
System.out.println("==========");
|
||||
System.out.println(m);
|
||||
System.out.println("++++++++++++++++++++");
|
||||
for (Piece p: m.getPieces()){
|
||||
System.out.println(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user