1 of 17

Labs 5.1 – Dungeon

Procedural Content Generation for Computer Games

Vojtěch Černý

cerny@gamedev.cuni.cz

2 of 17

Prerequisites

  • Windows / Mac / Linux
  • Java 8+
  • (Recommended) IntelliJ IDEA
    • Community edition suffices
    • As a student you can get Ultimate by just entering your student number

3 of 17

The Task

This homework will have two parts:

  • Part 1 – dungeon generator
  • Part 2 – roguelike game (using the dungeon generator)

This is part 1.

As always, aim for at least GameJAM quality

4 of 17

Codebase

Start with the roguelike repo

  • JVM target only for now, but will support JS targets in the future
    • If you use Kotlin for this task, you will have a browser build then
  • Sources are in src/jvmMain/kotlin/cz/cuni/gamedev/nail123
  • It uses Zircon for tileset management
  • Check out the Wiki

There are two Gradle tasks (run by ./gradlew <task>)

  • renderPng – will generate a PNG file into the out directory
  • playGame – lets you explore the dungeon with a character

Try running them (first run will fail!).

5 of 17

Variants

You should pick one of the following options:

1) write your own (non-trivial) generator

2) tweak Wave Function Collapse

Java or Kotlin:

  • to work in Java, change defaultWorld in GameConfig to SampleJavaWorld

6 of 17

Variant 1 – generate own dungeon

  • Generate a dungeon (of rooms and corridors)
  • Use something non-trivial – see examples below

Forbidden methods

Using noise

Using cellular automata

Acceptable methods

Approaches from lecture 5:

  • Binary division
  • Maze-first / maze-last

Graph / Shape grammars (may be hard)

or anything creative, write me if you have an idea, if it’s non-trivial I will accept it

7 of 17

Variant 1 - How to

  • Modify world/worlds/SampleWorld.kt
  • You can check DungeonWorld.kt or WaveFunctionCollapsedWorld.kt for some inspiration

8 of 17

Variant 1 - Criteria

  • Working generator with rooms – 2 pts
  • Corridors – 0.5pt
  • Exit (stairs) placed reachably, but far away from player – 0.5pt
    • Easy when using Pathfinding.kt::floodFill

9 of 17

Variant 2 – tweak Wave Function Collapse

10 of 17

Variant 2 – tweak Wave Function Collapse (WFC)

  • The repository contains a wave function generator for levels in

world/worlds/WaveFunctionCollapsedWorld1, using

world/builders/wavefunctioncollapse/WFCAreaBuilder

  • As source, it uses levels/wfc_sample.txt
  • It has 2 weaknesses:
    • It creates rooms not connected to the dungeon
    • It creates too many cycles
  • Add a post-processing step, to:
    • Reconnect floating rooms to the rest of the dungeon
    • Have less cycles (e.g. fill some corridors)

11 of 17

Variant 2 - How to

  • Modify world/worlds/WaveFunctionCollapsedWorld.kt
    • or Java world/worlds/WaveFunctionCollapsedJavaWorld.java
  • Use this world in GameConfig.kt

  • Add a post-processing step to the buildLevel function
  • You can also modify resources/levels/wfc_sample.txt
    • It may help with the cycles

  • Hint - Pathfinding::floodFill might be a useful function

12 of 17

Variant 2 - Criteria

  • Adding connectivity to all areas – 2pts
  • Removing cycles – 1pt

13 of 17

Bonus point

Get your own tileset

  • recommended 16x16px, otherwise adjust constants in GameConfig.kt
  • find a suitable one for a whole roguelike (with monsters, items, …)

Howto:

  • create a folder in the tilesets directory, add as png in there
  • add metadata tileinfo.yml
    • follow the kenney_superscaled_16x16 tileset example, or see documentation
  • modify tiles constants in roguelike/tiles/GameTiles.kt
  • 1 bonus point

14 of 17

Bonus points

  • Find a tileset with 47 tiles autotiling and adjust the tiling in GameTiles.kt so it works

  • 2 bonus points

15 of 17

Submission details

  • Send your solutions to cerny@gamedev.cuni.cz
  • Prefix the subject with “NAIL123-HW5.1”
  • Submit:
    • whole project (link to git or zipped)
      • Don’t forget to have comments in your code!
    • 3 screenshots (rendered via renderPng gradle task)
    • describe your approach
    • describe what you have tried, what worked or didn’t, the problems you faced
    • how much time you spent with the project (will not be part of evaluation)
  • Deadline is 18.5.
    • If you need more time, talk/write to me before the deadline

16 of 17

Questions / Problems

  • You can always e-mail me at cerny@gamedev.cuni.cz
  • I’m also frequently online at Discord https://discord.gg/4nfAzG

17 of 17

Q & A

Vojtěch Černý

cerny@gamedev.cuni.cz