1 of 30

Prerequisites

  • Java 17 or newer (pre-configured to Java 21)
    • Make sure your PATH and JAVA_HOME env. variables point to it
  • Windows / Mac / Linux
  • GIT
    • Usable from some shell / Command Prompt
  • (Recommended) IntelliJ IDEA
    • Community edition suffices
    • As a student you can get Ultimate by just entering your student number

2 of 30

Procedural Content Generation for Computer Games

Labs 1 - Minecraft

3 of 30

About Minecraft

  • Created by Markus Persson (Notch) in 2009 (released 2011)
  • Later bought by Microsoft, 180 million copies sold (!)
  • Life in an editable voxel world

4 of 30

Survival mode

  • Start with nothing and try to change the world to your liking ☺
  • World is 1m x 1m x 1m blocks

  • The main mode Minecraft is played

5 of 30

Technical info

  • Minecraft was originally written in Java
  • Currently has two versions (similar except for small details):
    • Minecraft Java edition – has more community plugins
    • Minecraft for Windows 10 (formerly Bedrock edition) – cross play on Windows, Mobile, Xbox, etc.
  • Tested by using Java 21

  • Official client is a paid game, running a server is free
  • NOTE: Owning the game is not a requirement to pass the homework
    • But, if you want, you can buy Minecraft at

https://www.minecraft.net/en-us/store/minecraft-java-edition

6 of 30

Terrain in Minecraft

  • The height coordinate is Y

  • The height of the world is 384 blocks (increased from 256 in 1.18)
  • Separated into chunks of 16 x 16 that are generated dynamically when player first comes close
  • From layer 60 it contains indestructible bedrock (but caves can go until -64)
  • Layer 62 is the sea-level
  • Layer 127 is the cloud layer
  • Ores spawn at different layers, e.g. diamond ore is very deep

7 of 30

The challenges

  • Terrain is volumetric, so just a heightmap is not good
  • The world is (practically) infinite

8 of 30

The Homework

  • Write a procedural terrain generation for Minecraft!

9 of 30

The Repository

Start with minecraft-terrain from the repo, which contains a Gradle buildsystem to instatiate server with a custom terrain generation plugin.

Using IntelliJ IDEA as IDE is highly recommended

Two tasks:

    • runServer - runs a Minecraft server with plugin (useless if you don’t own MC)
      • Runs indefinitely - type “stop” to stop it
    • generateMap – just generates a map into a PNG file (build/render/map.png)

The first run may take a few minutes to complete. Java >=17 required.

After the first run and error, edit server/eula.txt – set it to true.

Put your changes into MCWorldGenerationPluginKotlin/src/main/kotlin/cz/cuni/gamedev/nail123/mcworldgeneration/CustomChunkGeneratorKotlin.kt

10 of 30

Kotlin / Java options

  • Using Kotlin is optional
  • For Java, switch the constant in: cz/cuni/gamedev/nail123/mcworldgeneration/PluginLanguage.kt
  • And put changes in: cz/cuni/gamedev/nail123/mcworldgeneration/CustomChunkGeneratorJava.java

11 of 30

Testing it out

  • Run gradlew build
  • Run gradlew generateMap (will be in build/render)
  • Run gradlew runServer (and then type “stop”)

WARNING: First run will fail, you need to accept eula.txt in server/.

  • Optional: Switch the default language to Java
  • Alter the modifying generator – add a new height interval, that maps to any material (e.g. pumpkins)
  • For the map generator to recognize it, map it to some color in cz/cuni/gamedev/nail123/mcworldgeneration/visualizer/Material2Hue.kt
  • Generate map with your new material

12 of 30

Getting Minecraft

13 of 30

Criteria

  • You must do at least one of the following tasks:
    • Separate the world into biomes
    • Generate caves for exploration

  • Perlin and Simplex noise generators are available to you
  • Generally try to achieve results you would be happy to put into your own game
    • So try out some things, e.g. different noises, domain warping, …
  • Also see lecture slides for more info about methods

14 of 30

Option 1 - Biomes

  • Recommended if you don’t own Minecraft
  • Have at least three biomes, e.g. mountains, grassland, desert, sea…
  • Use noise to generate the biomes
    • Unless using a Whittaker diagram, any biomes should be allowed to touch
  • Each biome must have different parameters for terrain generation (e.g. flat deserts, tall mountains, …)
  • Also, ensure the transitions are smooth (interpolate)
  • Optionally use a (any) Whittaker diagram - for points

15 of 30

Option 1 – Biomes - Challenges

  • How to use noise to part an infinite plane into biomes?
  • How to interpolate surroundings?
    • Linear interpolation is fine, but you may also use smoothstep

16 of 30

Option 1 – Hints

  • Decomposition into biomes should be step 1 of generation, then you can use biome-info in further steps to provide large-scale variability
  • Use Gradle task generateMap often
    • Alter file Material2Hue.kt to add more colors to visualizer
    • Alter the corresponding Main.kt to change resolution of render
  • If running Minecraft, don’t forget to run deleteMap to regen map
  • Stop server by typing stop

17 of 30

Option 1 - Criteria

  • Reasonable partition into biomes – 1pts
  • Smooth transitions (in heightmap) between biomes – 1pts
  • (self-created) Whittaker diagram used – 1pt

18 of 30

19 of 30

Original Minecraft: Grassland, Jungle, Swamp, Badlands, Desert, Grassland biomes meeting

20 of 30

Acceptable solution:

A reasonable heightmap with transitions

BIOMES:

Mountains (White)

Desert (Yellow)

Grassland (Green)

Sea (Blue)

21 of 30

Acceptable solution: Three biomes meeting (Sea, Grassland and Mountains)

22 of 30

Option 2 – Caves

  • Use Perlin worms for Caves
    • (apparently what Minecraft uses)
    • Generates nice and long caves that are suitable for exploration

  • Optionally add deposits of Coal, Iron and Diamond underground

23 of 30

Option 2 – Challenges

  • Random walks:
    • How to get all walks that intersect a given chunk (in infinite world)?
  • Perlin worms:
    • Thresholding a noise (e.g. to <-0.1,0.1>) in 3D creates “crumpled” planes. How to get worm-shaped structures?
    • Ans: Use two Perlin worm (planes) and use their intersection

24 of 30

Option 2 – Hints

  • Start with generating just in 2D

Random walks:

    • Use spherical coordinates

Perlin worms:

    • Thresholding 3D noise results in a “cloth-like” shape (topologically deformed plane). How do you get the “worm-like” shape by using this method?
  • Gradle task generateMapGrayscale may help visualize

25 of 30

Option 2 - Criteria

  • Methods that generate findable and explorable caves – 2pts
  • Ores (Iron, Diamond, Coal) that spawn in different levels and in reasonable quantities – 1pt

26 of 30

Original Minecraft: X-ray view into Minecraft caves

27 of 30

Acceptable solutions using:

  • Random walks
  • 2D perlin worms
  • 3D perlin worms

Try and guess which is which

28 of 30

Option 3 – Your Experiment!

  • If there’s something cool you would like to try in Minecraft generation, come to discuss it and it may become your homework!

  • It should still be (at least in part) terrain generation

  • Examples:
    • A different approach to biomes or caves
    • Implementing Teardrop
    • Some cool algorithm

29 of 30

Submission details

  • Submit via this form
  • Submit:
    • one file of Kotlin or Java (human-readable, commented)
      • If you want to use more classes, use internal ones
    • describe all you have tried, what worked or didn’t, the problems you faced
    • at least 3 screenshots (either rendered heightmaps or from Minecraft)
    • how much time you spent with the project (will not be part of evaluation)

  • Deadline is 28.3.
    • If you need more time, talk/write to me before the deadline

30 of 30

Questions / Problems

  • Discord (private/public)!

  • One final recommendation:

Allocate more than one session to work on the project. If you get stuck on some issue, it’s good to clear your head for a bit and return to it later.