██████╗ ██████╗ ███████╗██╗ ███████╗███████╗████████╗
██╔════╝ ██╔═══██╗ ██╔════╝██║ ██╔════╝██╔════╝╚══██╔══╝
██║ ███╗██║ ██║█████╗█████╗ ██║ █████╗ █████╗ ██║
██║ ██║██║ ██║╚════╝██╔══╝ ██║ ██╔══╝ ██╔══╝ ██║
╚██████╔╝╚██████╔╝ ██║ ███████╗███████╗███████╗ ██║
╚═════╝ ╚═════╝ ╚═╝ ╚══════╝╚══════╝╚══════╝ ╚═╝
A terminal-based multiplayer Battleship game built with Go, featuring real-time ASCII graphics and TCP networking.
- Multiplayer: Real-time 1v1 gameplay over TCP
- Visual: Beautiful ASCII game boards with live updates
- Simple Commands: Easy-to-use command interface
- No Dependencies: Uses only Go standard library
- Grid: 10x10 battlefield (A1 to J10)
- Ships: Each player places 5 single-cell ships
- Turns: Players take turns firing at coordinates
- Win Condition: Destroy all enemy ships to win
git clone https://github.com/ahmaruff/go-fleet
cd go-fleet
go mod tidy
go build -o server cmd/server/main.go
go build -o client cmd/client/main.go
./server --port 8080
Terminal 1:
./client --host localhost --port 8080
Terminal 2:
./client --host localhost --port 8080
- Enter your name when prompted
- Type
/ready
to join matchmaking - Place ships:
/set A1
,/set B2
, etc. - Fire at opponent:
/fire C3
,/fire D4
, etc.
Command | Description | Example |
---|---|---|
/name <name> |
Set your player name | /name Alice |
/ready |
Join matchmaking queue | /ready |
/set <coord> |
Place ship at coordinate | /set A1 |
/fire <coord> |
Fire at enemy coordinate | /fire B3 |
/quit |
Exit the game | /quit |
1. Players connect and set names
2. Both players send /ready → matched automatically
3. Ship Placement Phase:
- Each player places 5 ships using /set
- Real-time board updates
4. Combat Phase:
- Players fire using /fire commands
- See hit/miss results instantly
5. Victory:
- First to destroy all enemy ships wins
go-fleet/
├── cmd/
│ ├── server/
│ │ └── main.go # Game server handler
│ ├── client/
│ │ └── main.go # Game client handler
│ └── test/
│ └── main.go # Simple e2e test
├── internal/
│ ├── game/ # Core game logic
│ │ ├── board.go # Game board and ship management
│ │ ├── game.go # Game state and flow control
│ │ ├── player.go # Player data structure
│ │ └── coordinate.go # Coordinate conversion
│ ├── display/
│ │ └── display.go # Game UI rendering
│ └── effects/
│ └── effects.go # ASCII Art Effect
├── .gitignore
├── go.mod
├── LICENSE
└── README.md
- Server: Manages multiple games, handles matchmaking, coordinates turns, sends effect game state to client
- Client: Connects to server, sends commands, displays game state
- Game Logic: Pure game rules independent of networking
- Display System: Game ASCII rendering with real-time updates
- Effects: ASCII Art effect for each game state
========================================== GO-FLEET ==========================================
Player: Alice vs Bob | Phase: PLAYING | Current Turn: Player 1
===========================================================================================
Your Board: Opponent's Board:
A B C D E F G H I J A B C D E F G H I J
1 S ~ ~ ~ ~ ~ ~ ~ ~ ~ 1 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
2 ~ S ~ ~ ~ ~ ~ ~ ~ ~ 2 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
3 ~ ~ S ~ ~ ~ ~ ~ ~ ~ 3 ~ ~ X ~ ~ ~ ~ ~ ~ ~
4 ~ ~ ~ S ~ ~ ~ ~ ~ ~ 4 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
5 ~ ~ ~ ~ S ~ ~ ~ ~ ~ 5 O ~ ~ ~ ~ ~ ~ ~ ~ ~
6 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 6 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
7 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 7 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
8 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 8 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
9 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 9 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
10 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ 10 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Commands: /ready, /set A1, /fire B2
Symbol | Meaning |
---|---|
~ |
Water / Unknown |
S |
Your ship (not hit) |
X |
Hit (ship destroyed) |
O |
Miss (water hit) |
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.