Skip to content

ahmash11/Battleship

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚓ Battleship (Single Player CLI)

A C-based command-line implementation of the classic Battleship game featuring dynamic memory management and a computer opponent.

🚀 Overview

This project recreates Battleship as a single-player experience where users compete against an AI opponent with randomized targeting.

It emphasizes low-level memory control, struct-based architecture, and clean system design in C.

✨ Features

  • Interactive ship placement
  • Computer opponent with randomized AI
  • Three-board display system:
    • Player shots
    • Enemy shots
    • Player ships
  • Win detection system

🧠 Engineering Concepts

  • Dynamic memory allocation (malloc / free)
  • Struct-based state management
  • Modular design with header files
  • Memory safety (Valgrind clean)

📂 Project Structure

main.c battleship.c battleship.h

▶️ How to Compile & Run

gcc -g main.c battleship.c -o battleship
./battleship

🔍 Memory Testing

valgrind ./battleship

🎯 Engineering Highlights

  • No global state — uses structured game state passing
  • Efficient grid representation
  • Clean separation between logic and interface
  • Memory-leak-free implementation

🔮 Future Improvements

  • Smarter AI (hunt/target strategy)
  • Multiplayer support
  • GUI version

👤 Author

Ahmed Al-Mashraie

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages