Island

Discover and explore wild islands!

View project onGitHub

Working with Islands

Generating Islands

To ease the burden of building sequences of processors in a repetitive manner, we provide a DSL named DiSLand targeting this task. To use it in your system, simply mix the DiSLand trait when you need it.

The following code snippet create an Island looking like the famous Tortuga Island from Pirates of the Caribbean movies.

val tortuga: IslandMap =  {
  createIsland shapedAs ellipsis( x = 95.percent, y = 40.percent, 
                                  theta = 20) builtWith Seq(
    plateau(45), flowing(rivers = 30, distance = 60.percent), 
    withMoisture(soils.wet, distance = 100),
    AssignPitch, usingBiomes(WhittakerDiagrams.caribbean)
  ) usingSeed 0x24F84E32B98D3CF5L withSize 1600 having 3000.faces
}
  • The island is shaped as an ellipsis slightly inclined (20º), taking 95% of the horizontal axis of the map and 40% of the vertical one;
  • We use a maximal altitude of 45 pixels (450 meters);Caribbean
  • We ask for 30 rivers to be created on the map, and their source must be located inside the lands (60% of the maximal distance to the coast)
  • The soil keeps water by nature (wet), and a source of water irrigate up to 100 pixels (1 kilometer).
  • Tortuga is a Caribbean island, we use a Whittaker diagram modeling Caribbean biomes such as TROPICAL_RAIN_FOREST.
  • We also compute the pitch of each face, as this information is useful to decide if a face is easy to exploit (i.e. almost flat) or on the contrary difficult to exploit;
  • The map will contain 3,000 faces, on a 1600x1600 pixels^2 area (256 km^2)
  • Finally, we assign a seed to the random generator, so the generation is deterministic.

Using this island map, one can obtain a PDF file that depicts the map. We can also project the map according to a given property, generating a heat map associated to this property. Here, we ask for the generation of a blue one representing the soil moisture generated by acquiferous resources (rivers and groundwater tables).

Serializing Islands

The project relies on a JSON format to serialize a given Island into a file. The following code instantiates the Tortuga island, save it into a file and read it again, checking the correctness of the serialize/deserialize process.

object SerializeIsland extends App with DiSLand {

  val tortuga = ... 
  
  // Save a given map into a JSON file
  IslandMapFactory(tortuga, new File("./tortuga.json"))

  // Load the file contents and instantiate a map from it
  val loaded = IslandMapFactory(new File("./tortuga.json"))

  println(loaded == tortuga))

}

Warning: Using JSON as storage format is verbose and generate large files. In the previous example, tortuga.json weights ~2Mb. However it is quicker to load 2Mb from the disk than to re-compute the generation when island are “complicated”.

Exporting Islands as Images

object ExportPDFs extends App with DiSLand {
  
  val tortuga = ... 
  
  // Exporting the map as PDF files
  tortuga -> ("tortuga" as pdf)
  tortuga -> ("tortuga-moisture" as heatMap(HasForMoisture(), Color.BLUE))
 
}

The execution of the previous code generates two PDF files: tortuga.pdf and tortuga-moisture.pdf.

Tortuga map created

Tortuga moisture heat map created