A browser-based version of the classic Netrek game. Play instantly in your web browser - no installation required!
- Visit the server in your browser:
http://server-address:8080 - Enter your name and choose a team
- Click "Enter Game" to start playing
# Install the server
go install github.com/lab1702/netrek-web@latest# Run the server
netrek-web# Or run on custom port
netrek-web -port 3000Server is now running at http://localhost:8080
- Left Click: Fire torpedo
- Middle Click: Fire phaser
- Right Click: Set course
- 0-9: Set speed
- S: Shields
- O: Orbit planet
- R: Repair
- L: Lock on target
- C: Cloak
- T/Y: Tractor/Pressor beam
- P: Plasma torpedo
- D: Detonate torpedoes
- B: Bomb planet
- Z/X: Beam armies up/down
- A: Message all
- Shift+T: Team message
- ?: Help window
- \: Practice mode (add bots)
Prerequisites: Go 1.25+
git clone https://github.com/lab1702/netrek-web.git
cd netrek-web
go build
./netrek-webdocker build -t netrek-web .
docker run -d -p 8080:8080 netrek-web- 4 teams with 40 planets
- 6 ship types (Scout, Destroyer, Cruiser, Battleship, Assault, Starbase)
- Real-time space combat
- Tournament mode (4v4+)
- Practice mode with bots
- Team messaging system
The project is organized into clear modules for maintainability and scalability:
-
Handler Modules: Focused, modular message handlers
game_state_handlers.go- Login and quit handlersmovement_handlers.go- Movement, orbit, and lock handlerscombat_handlers.go- Weapons and combat systemsship_management_handlers.go- Repair, beam, and bomb handlerscommunication_handlers.go- All messaging systemsbot_handlers.go- Bot management commandshandler_utils.go- Shared utilities and data structures
-
Game Engine: Core game mechanics and systems
websocket.go- WebSocket handling and game loopphysics.go- Physics simulation and collision detectionprojectiles.go- Torpedo and projectile systemssystems.go- Ship systems (shields, weapons, engines)planets.go- Planet mechanics and interactionstournament.go- Tournament mode logicvictory.go- Victory conditions and game ending
-
Bot AI System: Intelligent computer opponents
bots.go- Main bot coordination and initializationbot_combat.go- Combat decision-making and targetingbot_navigation.go- Movement and pathfindingbot_planet.go- Strategic planet capture decisionsbot_weapons.go- Weapon firing and aim calculationbot_jitter.go- Position randomization to prevent clusteringbot_helpers.go,bot_types.go- Supporting utilities
-
Utilities: Supporting systems
intercept.go- Advanced torpedo targeting calculationsgame_helpers.go- Game utility functions
index.html,game.html- Landing page and game interfacenetrek.js- Main game client and WebSocket communicationship-renderer.js,planet-renderer.js- Rendering systemsinfo-window.js- HUD and information displaysship-bitmaps-all-teams.js- Ship sprite dataconvert_bitmaps.js- Utility to convert X11 bitmap data for planet sprites
types.go- Core game data structuresplanets.go- Planet configurations and initializationtorp.go- Torpedo physics and range calculations
This modular structure enables:
- Clear separation of concerns
- Easy navigation to specific systems
- Parallel development without conflicts
- Comprehensive test coverage
- Maintainable and extensible codebase
The project includes comprehensive test coverage for all critical systems:
- Game Logic:
game/torp_test.go- Torpedo physics and range calculations - Server Core:
server/handlers_test.go- HTTP and WebSocket handlersserver/harness_test.go- Test harness utilitiesserver/test_helpers.go- Testing support functions (helper file)
- Bot AI System:
server/bots_test.go- Bot behaviors and decision-makingserver/bot_combat_test.go- Bot combat improvements and targetingserver/bot_jitter_test.go- Position jittering system
- Combat Systems:
server/starbase_fire_test.go- Starbase weapon systemsserver/weapon_direction_test.go- Weapon targeting calculationsserver/orbit_weapons_test.go- Orbital velocity and weapon accuracy
- Game Features:
server/tournament_test.go- Tournament mode logicserver/victory_test.go- Victory condition testingserver/formatting_test.go- Message formatting tests
- Utilities:
server/intercept_test.go- Advanced targeting algorithms
# Run all tests
go test ./...
# Run with verbose output
go test -v ./...
# Run with coverage report
go test -cover ./...
# Run specific test package
go test ./server
go test ./game
# Code quality checks
go fmt ./...
go vet ./...
go build ./...Based on the original Netrek (1986). Visit https://www.netrek.org/ for the classic game.
Educational implementation. Original Netrek is open source.