<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Altaaf8901</title>
    <description>The latest articles on DEV Community by Altaaf8901 (@altaaf8901).</description>
    <link>https://dev.to/altaaf8901</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3948692%2Ff8454eeb-d689-4c40-9a9a-d04c25159aba.png</url>
      <title>DEV Community: Altaaf8901</title>
      <link>https://dev.to/altaaf8901</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/altaaf8901"/>
    <language>en</language>
    <item>
      <title>Building a Mini Battleship Game in Python</title>
      <dc:creator>Altaaf8901</dc:creator>
      <pubDate>Sun, 24 May 2026 07:31:42 +0000</pubDate>
      <link>https://dev.to/altaaf8901/building-a-mini-battleship-game-in-python-3fhb</link>
      <guid>https://dev.to/altaaf8901/building-a-mini-battleship-game-in-python-3fhb</guid>
      <description>&lt;p&gt;For my Codecademy portfolio project, I built a &lt;strong&gt;Mini Battleship terminal game&lt;/strong&gt; using Python.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How the Game Works&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The game uses two boards:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;hidden board&lt;/strong&gt;, which stores where the ships actually are&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;visible board&lt;/strong&gt;, which is what the player sees in the terminal&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The hidden board acts like the answer key. The visible board starts with all unknown spaces, and it updates when the player guesses.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Python Concepts I Used&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
This project helped me practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Functions&lt;/li&gt;
&lt;li&gt;Lists&lt;/li&gt;
&lt;li&gt;Nested lists&lt;/li&gt;
&lt;li&gt;Loops&lt;/li&gt;
&lt;li&gt;Conditionals&lt;/li&gt;
&lt;li&gt;Random number generation&lt;/li&gt;
&lt;li&gt;User input&lt;/li&gt;
&lt;li&gt;Input validation&lt;/li&gt;
&lt;li&gt;Basic game state tracking&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What Was Difficult&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The hardest part was understanding how the hidden board and visible board should work together.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;What I Learned&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
This project taught me that programming is not just about writing code line by line. It is also about organizing logic clearly.&lt;/p&gt;

&lt;p&gt;I had to break the game into smaller parts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating the board&lt;/li&gt;
&lt;li&gt;Placing ships&lt;/li&gt;
&lt;li&gt;Asking for guesses&lt;/li&gt;
&lt;li&gt;Checking if a guess was a hit or miss&lt;/li&gt;
&lt;li&gt;Updating the visible board&lt;/li&gt;
&lt;li&gt;Controlling the full game loop&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Breaking the project into smaller functions made the program easier to understand and debug.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;GitHub Repository:&lt;br&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://assets.dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/Altaaf8901" rel="noopener noreferrer"&gt;
        Altaaf8901
      &lt;/a&gt; / &lt;a href="https://github.com/Altaaf8901/Portfolio-Project-MiniBattleShip-Game" rel="noopener noreferrer"&gt;
        Portfolio-Project-MiniBattleShip-Game
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      a small script that lets you play this game called battleships with a computer. 
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;


</description>
      <category>python</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
