Build Your Own World

A tile world built from a seed, where one search lights the rooms and finds the path

  • Java
  • Algorithms
  • Procedural generation
  • Game architecture

Overview

A tile world built from a seed, where one search lights the rooms and finds the path

Role
Architecture, half the classes
Team
Pair project
Timeline
Spring 2026
Course
CS 61B, UC Berkeley

A procedurally generated, explorable tile world in Java, built on the course tile engine with a pair partner. I designed the architecture and implemented half the classes: GameWorld, Room, Light and BFS, covering world generation, wall generation, the game loop, rendering, avatar movement and lighting.

GameWorldstate, the generation pipeline, the game loop
Roomplaces floors
LightBFS, depth 4
BFSone generic search
Mainmenu screens
Hallwayplaces floors
PathfinderBFS, no limit
SaveLoadseed and keystrokes

Ideation

Before writing code, we mapped the whole game as a flow chart: the menu (new game, load, theme, exit), entering a seed, building the world and its lights, and the game loop with movement, the hover bar, click-to-move and saving. It became our plan for which classes we needed and how they connect.

Building the world

The player types a numeric seed. It seeds one Random, and that Random drives every choice: how many rooms (8 to 14), their sizes and positions, the hallway paths, which lights are on. The same seed always makes the same world.

generateWorld() runs the pipeline: rooms place floors, hallways place floors, then generateWalls() sweeps every tile and turns any empty tile with a floor among its 8 neighbors into a wall, then lighting, then the avatar.

seed
theme
Example worlds drawn for this page; the project code stays private.

RationaleDeriving walls after floors keeps hallway-into-room joins clean, since neither rooms nor hallways ever draw a wall. Checking all 8 neighbors, not just 4, is what closes the corners of each room.

Save and load

Saving writes the seed plus every keystroke, and the theme and light states, to a text file. Loading regenerates the world from the seed and replays the keystrokes, instead of saving the whole grid.

Complexity, from our design doc (W×H tiles)

/ 01 Generating the world: O(W×H + N + E)
/ 02 Rendering, each frame: O(W×H + L)
/ 03 Pathfinding, worst case: O(W×H)