Help us measure site usage?

With your permission, we use self-hosted analytics to understand page usage. It is optional and does not affect the Service. Learn more.

JavabeginnercliAI generated

Text Adventure Game Engine

Build a text adventure game engine in Java for the console: the player explores rooms by typing commands such as go north, take lamp, use key, look and inventory, collects items and solves simple puzzles to win. The whole world, rooms, exits, items and puzzles, is loaded from a data file, so new adventures can be written without changing the code. It's a great first Java project: you'll learn designing classes (Room, Item and Player), collections such as Map and List, reading and parsing files, turning typed text into commands, keeping game state, and testing with JUnit.

Estimate
~9.5h
Steps
6
Completed by
0
Proposed by
codeseed.app

Java I/O · Collections

Project roadmap

  1. 01

    Design the game classes

    ~1.5h

    Create classes Room (id, name, description, exits as a Map from direction to room id, and items), Item (id, name, description and whether it can be taken), and Player (current room and inventory). Add a Game class holding the rooms in a Map and the player. Build a tiny two-room world in code to test with. Done when: the classes compile, and the tiny world can be created.

  2. 02

    Load the world from a file

    ~2h

    Design a simple text format (or JSON, read with a library such as Jackson or Gson) describing rooms, exits, items and puzzles, and write a loader that builds the Game from it. Check the data: exits point to existing rooms, item ids are unique, and the start room exists, reporting problems with line numbers or names. Done when: a world file loads, and a file with a broken exit reports a clear error.

  3. 03

    Parse commands

    ~1.5h

    Write a parser that reads a line with Scanner, lowercases it, splits it into words, and recognizes verbs and their synonyms (go and walk, take and get, and n, s, e and w for directions) plus an optional object. Return a Command object, or a helpful message for input it doesn't understand. Done when: go north, n and walk north produce the same command.

  4. 04

    Add puzzles

    ~2h

    Implement the actions: moving, look, examine, take and drop, inventory, and use item. Add locked exits that open when the right item is used, and items that are hidden until something is examined. Show the room's description, exits and items when entering it. Done when: a puzzle requiring a found key to unlock a door can be solved.

  5. 05

    Add a win condition

    ~1h

    Define the goal in the world file (for example reaching a room while carrying a certain item), check it after each command, and end with a victory message showing the number of moves. Add a quit command and a help command listing the verbs. Done when: a complete adventure can be played from start to win.

  6. 06

    Test it

    ~1.5h

    Write JUnit 5 tests: loading valid and broken world files, parsing commands and synonyms, moving through open and locked exits, taking and using items, and reaching the win condition through a scripted list of commands. Done when: all tests pass.

Ready to build this?

Get a GitHub repo and start building. Your AI reviewer checks each step as you go.

~9.5h · 6 steps

Tech stack

Java I/OCollections