A command‑line implementation of the classic Battleship game in Java, featuring ANSI‑colored console output for a more vivid and engaging terminal experience. When we were assigned to build a Battleship game as part of learning Java, I decided to go a bit further and explore what could be done with Java in a pure CLI environment. That led me to create a small “graphic” engine (which I’ll publish as a separate repo) built around chaxels — character‑pixels that allow fine‑grained control over foreground color, background color, z‑index layering, and even faux opacity. The result is that this project became not only a Battleship game, but also a demo of the chaxel engine in action — including effects like translucent clouds drifting over the sun.
The name UltraVersenker is a nod to the German word Schiffeversenken (Battleship) and reflects my attempt to create an “ultimate” command‑line version of the game. With the help of my chaxel‑based CLI engine, the goal was to push a simple terminal Battleship far beyond the usual text‑only experience.
(*Here you can see a typical battle: your main ship is down, you fire at the enemy, the future is uncertain. Yet the semitransparent cloud is over the sun. Chaxel engine works, even when the world is not*)
Because this was a learning project, all Java code was written by me without the assistance of AI/LLMs (aside from standard inline completion tools). The JavaDocs and this Markdown file were generated with the help of an LLM and then edited by me.
- Classic Battleship gameplay with human vs AI (computer)
- Computer Player implementation (AI) with four difficulty levels (easy, medium, hard, and hard+).
- ANSI styling for colorful and formatted console output using the custom Fansi utility
- Keyboard input handling via jnativehook
- Custom rendering system with chaxels (character-based graphics)
- Modular architecture with utilities, game logic, and bridges
- Java 24 or higher
- Maven 3.6+
- Windows (currently, due to CLI launcher specifics)
-
Clone the repository:
git clone https://github.com/yourusername/UltraVersenker.git cd UltraVersenker -
Build with Maven:
mvn clean compile
Run the game directly with Maven:
mvn exec:java -Dexec.mainClass="JavaBattleShips.UltraVersenker"Or package and run the JAR:
mvn package
java -jar target/UltraVersenker-1.0-SNAPSHOT.jarThe game will launch in a new command prompt window on Windows. Or you can run it in your favorite IDE (I have tested it in IntelliJ and VS Code).
UltraVersenker/
├── src/
│ ├── main/java/
│ │ ├── commonutils/ # Utility classes
│ │ │ ├── Ansi.java
│ │ │ ├── Fansi.java # ANSI styling utility
│ │ │ ├── ParamLine.java
│ │ │ ├── STools.java
│ │ │ └── menudispatcher/ # Menu system utilities
│ │ └── JavaBattleShips/ # Main game package
│ │ ├── bridges/ # Abstractions for input/output
│ │ ├── chaxels/ # Character-based graphics
│ │ ├── chaxelshapes/ # Predefined shapes
│ │ ├── clrender/ # Command-line rendering
│ │ ├── keymaster/ # Keyboard input handling
│ │ ├── logic/ # Game logic and AI
│ │ └── relauncher/ # CLI launcher
│ └── test/java/ # Unit tests
├── pom.xml # Maven configuration
├── README.md # This file
├── .gitignore # Git ignore rules
└── LICENSE # License file
To run the game from an IDE, you need to go to the src/main/java/JavaBattleShips/Ultraversenker.java
Run tests with Maven:
mvn test- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Run
mvn testto ensure everything passes - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Uses jnativehook for global keyboard input
- Custom Fansi library for ANSI console styling (check AnsiFansi out!)
- SmartFutureCampus for support and help