A strategic multiplayer territory control game played on a hexagonal grid, featuring AI opponents and real-time multiplayer gameplay.
- Online Multiplayer: Play with friends in real-time using room codes
- AI Opponents: Challenge AI with 3 difficulty levels (Easy/Medium/Hard)
- Local Multiplayer: Pass-and-play on the same device
- Hexagonal Grid: Unique 6-sided tile system creates fresh strategic possibilities
- 20 Unique Pieces: Polyhex pieces from 1-5 hexagons in various configurations
- Strategic Depth: Territory control through diagonal-only connections
HexTactics is an abstract strategy game for 2-4 players. Each player starts with 20 polyhex pieces in their color.
Claim as much territory as possible by placing your pieces on the hexagonal board. The player with the lowest score (fewest hexagons remaining) wins!
- First Move: Your first piece must cover your starting hex (marked on the board)
- Diagonal Connection: Each subsequent piece must touch at least one of your existing pieces, but only at corners (diagonally)
- No Edge Sharing: Your pieces cannot share edges with each other (only diagonal touches allowed)
- Blocking: You can block opponents by occupying hexes they need
- Scoring: You start with points equal to total hexagons in all pieces. Each hex you place reduces your score by 1. Lower score is better! Bonus: -20 points if you place all pieces, -10 more if your last piece is the single hex!
- Place Large Pieces First: Secure high-value pieces early before space runs out
- Maximize Diagonal Connections: Create as many diagonal connection points as possible
- Control Territory: Spread across the board to maintain placement options
- Block Opponents: Cut off their expansion routes strategically
- Stay Centered: Avoid board edges to preserve future moves
# Install dependencies
npm install
# Run the game (starts both client and server)
npm run devThe game will be available at http://localhost:5173
-
Choose your game mode:
- Online Game: Get a room code to share with friends
- vs AI: Play against computer opponents
- Local Multiplayer: Pass-and-play on one device
-
Select number of players (2-4)
-
For AI mode, choose difficulty level
- Select a piece from your collection on the right
- Use Rotate 60° and Flip buttons to orient the piece
- Move your mouse over the board to preview placement
- Click to place the piece
- Pieces must follow the diagonal-connection rule
- Player 1 creates a room and gets a 6-character code
- Other players join using that code
- Once at least 2 players are ready, start the game
- Take turns placing pieces
- Frontend: React with Canvas-based hexagonal rendering
- Backend: Node.js + Express + Socket.IO
- Game Logic: Axial coordinate system for hexagonal grid
- AI: Greedy algorithm with heuristic evaluation
- Rotation Fix: Corrected hexagonal piece rotation to prevent expansion during gameplay (see
ROTATION_FIX.md)
The game uses axial coordinates (q, r) for the hexagonal grid:
- Each hex has 6 neighbors (edges) and 6 diagonal neighbors (corners)
- Pieces must connect at diagonal neighbors only
- Board is a circular hex grid with radius 10
The AI evaluates moves based on:
- Piece size (larger pieces prioritized)
- Distance from board center
- Random variation for unpredictability
blockai/
├── src/ # React frontend
│ ├── components/ # UI components
│ │ ├── HexBoard.jsx # Hex grid canvas renderer
│ │ └── Menu.jsx # Main menu
│ ├── App.jsx # Main app component
│ └── main.jsx # Entry point
├── server/ # Node.js backend
│ └── index.js # WebSocket server
├── shared/ # Shared game logic
│ ├── hexPieces.js # Polyhex piece definitions
│ ├── hexGameLogic.js # Game rules engine
│ ├── hexGrid.js # Hexagonal grid utilities
│ └── hexAI.js # AI opponent
└── package.json # Dependencies
HexTactics is a deterministic, perfect-information abstract strategy game based on:
- Polyhexes: Mathematical shapes from combinatorial game theory (hexagonal polyominoes)
- Territorial Control: Area control mechanics on hex grid
- Greedy Optimization: AI prioritizes immediate high-value moves
- Spatial Reasoning: Geometric puzzle-solving in hexagonal space
- Diagonal Advantage: Maximizing future move options through diagonal connections
Hexagons offer unique strategic properties:
- 6 directions instead of 4 (square grid)
- Equal distance to all neighbors (no diagonal vs orthogonal distinction)
- Natural tessellation creates organic flow
- Different spatial relationships than square grids
Original concept inspired by classic territory control games. This is an original implementation using hexagonal grid mechanics.
MIT License - Feel free to use and modify!