For my Codecademy portfolio project, I built a Mini Battleship terminal game using Python.
I chose Battleship because I wanted a project that was still beginner-friendly, but also forced me to think more deeply than a basic calculator or number guessing game. The goal of the game is simple: the computer hides ships on a 5x5 board, and the player tries to find them by guessing row and column coordinates.
How the Game Works
The game uses two boards:
- A hidden board, which stores where the ships actually are
- A visible board, which is what the player sees in the terminal
The hidden board acts like the answer key. The visible board starts with all unknown spaces, and it updates when the player guesses.
If the player guesses a ship location, the visible board marks that spot as a hit. If the player misses, the board marks that spot as a miss. The game continues until the player finds all the ships or runs out of guesses.
*Python Concepts I Used
*
This project helped me practice:
- Functions
- Lists
- Nested lists
- Loops
- Conditionals
- Random number generation
- User input
- Input validation
- Basic game state tracking
What Was Difficult
The hardest part was understanding how the hidden board and visible board should work together.
At first, I kept thinking that both boards would update at the same time, but I learned that they need to be separate. The hidden board stores the truth, and the visible board only shows what the player is allowed to see.
Another challenge was building the main game loop. I had to make sure the game kept running while there were still ships remaining and guesses left. I also had to fix issues where the game printed the lose message too early or did not update the visible board correctly.
*What I Learned
*
This project taught me that programming is not just about writing code line by line. It is also about organizing logic clearly.
I had to break the game into smaller parts:
- Creating the board
- Placing ships
- Asking for guesses
- Checking if a guess was a hit or miss
- Updating the visible board
- Controlling the full game loop
Breaking the project into smaller functions made the program easier to understand and debug.
Conclusion
Building this Mini Battleship game helped me understand how a simple terminal game can still involve real programming concepts. It gave me more practice with problem-solving, debugging, and organizing code into smaller pieces.
GitHub Repository:
Top comments (0)