Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sea Battle logo

Sea Battle

A colorful terminal Battleship game in C with random fleets, live statistics, and a clean firing map.

Quick start · Русский

C Terminal interface Makefile

Sea Battle terminal interface with firing map, hits, and misses

Why play it?

Sea Battle is a compact C project that turns the classic guessing game into a polished terminal experience. The computer places a fleet, you fire by coordinates, and the map tracks every hit and miss.

What you get Why it matters
Random fleet placement Every game is different. Ships never touch, even diagonally.
Adaptive board and fleet Choose a board from 5×5 to 20×20; the fleet scales to fit.
Clear terminal UI Colored map, readable status, and immediate hit or miss feedback.
Defensive input handling Invalid values and duplicate shots do not break the game.

Quick start

You need a C compiler such as gcc or clang.

make
./sea_battle

Or compile directly:

gcc game.c -o sea_battle
./sea_battle

The interface uses ANSI colors and looks best in a modern terminal.

Your first turn

Coordinates start at 0. On a 10×10 board, enter values from 0 to 9.

Number of rows (5-20): 10
Number of columns (5-20): 10
Reveal ships? (yes/no): no

Row: 4
Column: 7
✹ Hit!

Answer yes to reveal the fleet — useful for testing the placement logic. In a normal game, choose no and hunt blind.

Reading the map

Symbol Meaning
. not fired at yet
* miss
X hit
S ship, shown only in reveal mode

Fleet rules

On boards at least 10×10, the game uses the classic fleet:

Ship Count
■■■■ 1
■■■ 2
■■ 3
4

On smaller boards, the largest ship length is reduced so the fleet fits. Ships always have at least one empty cell between them.

Development

make       # build the game
make run   # build and run
make check # build with AddressSanitizer and UndefinedBehaviorSanitizer
make clean # remove the executable

Project layout

game.c                         # game logic and terminal interface
Makefile                       # build, run, and verification commands
docs/readme-assets/logo.svg    # README identity mark
docs/readme-assets/terminal-preview.svg  # README interface preview
README.md                      # English documentation
README.ru.md                   # Russian documentation
Good hunting. May every shot find its target.

About

Small "Sea Battle" game on C.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages