
Battleship
A command-line implementation of the classic Battleship game built in OCaml.
Tools Used
Github, Ubuntu, Visual Studio Code
Overview
Built a command-line Battleship game in OCaml featuring ship placement, turn-based gameplay, a single-player mode, and mini games preceding turns. Designed a modular system architecture and implemented core functions in grid and player modules, ensuring reliability through extensive testing. Collaborated across a 5-person team to deliver a cohesive, fully functional game experience.
Problem
The project challenged us to design a complex, interactive game entirely from scratch in OCaml, without relying on prior code or libraries. This required building a unified system architecture, creating robust gameplay logic, and ensuring consistency through rigorous testing. The project emphasized collaboration, modular design, and aligning individual contributions toward one cohesive product.
Gameplay

Developed grid system allowing players to place ships before match begins.

Constructed attack logic with real-time feedback for hits, misses, or sunk ships.

Built logic to track ship states and confirm when entire ship is destroyed.

Created a randomized opponent grid to enable solo play against computer.
Process & Key Contributions
To bring Terminal Battleship to life, I focused on both the core system architecture and the gameplay mechanics while ensuring code quality through a comprehensive testing framework.
Key Contributions:
Core Gameplay Development: Implemented major functions across grid.ml and grid.mli, including grid compilation unit (type cell, t), string_of_cell, check_if_hit, get_length, num_ships, random_grid, change_state, hit_ship, is_sunk, enter_player_name, single, and the rock_paper_scissors mini-game
Testing & Quality: Authored the majority of the test suite, including test_coordinates, test_string_of_cell, test_create_board, test_get_ships, test_hit_ship, test_is_sunk, test_get_length, test_num_ships, test_change_to_ship, test_change_state, test_grid, and test_validate_ship.
Debugging & Reliability: Took lead on debugging across modules, diagnosing logic errors in grid state transitions and ensuring seamless gameplay flow.
Collaboration & Leadership: Coordinated communications, managed deadlines, and ensured the team aligned on milestones, driving the project to completion.
Takeaways
Learned to perform extensive testing to ensure system reliability and consistency.
Developed stronger collaboration skills, working cohesively on shared codebases and merging concurrent contributions.
Gained hands-on experience with modular architecture and maintaining clean, scalable logic.
Discovered the importance of user feedback loops even in command-line interfaces for better clarity and flow.
Future Implementations
Add color-coded feedback (e.g., hits, misses, and sunk ships) to improve visibility.
Explore diagonal ship placement and additional grid modes for gameplay variety.