A browser-based implementation of the classic Ticket to Ride board game. Play solo against smart AI opponents or with up to 5 players!
- Full USA Map - 36 cities and ~100 routes across America
- 1-5 Players - Mix of human and AI opponents
- Smart AI - Strategic opponents that plan routes, collect cards, and block when beneficial
- Complete Rules - All official rules including longest route bonus (+10 points)
- Interactive Map - Click to claim routes, hover to see details
- Real-time Scoring - Track all players' progress on the scoreboard
- Game Log - Review all actions taken during the game
-
Clone this repository:
git clone https://github.com/baofeng-dong/ticket-to-ride.git cd ticket-to-ride -
Start a local web server:
python3 -m http.server 8080
-
Open your browser to: http://localhost:8080
- Select the number of players (2-5)
- Configure each player as Human or AI
- Enter player names
- Click "Start Game"
- Each player receives 4 train cards and chooses destination tickets
On your turn, choose ONE action:
| Action | Description |
|---|---|
| Draw Train Cards | Take 2 cards from face-up cards or deck. Taking a locomotive (wild) from face-up counts as both draws. |
| Claim Route | Play matching colored cards to claim a route between two cities. Gray routes accept any single color. |
| Draw Destinations | Draw 3 destination tickets and keep at least 1. |
| Route Length | Points |
|---|---|
| 1 car | 1 point |
| 2 cars | 2 points |
| 3 cars | 4 points |
| 4 cars | 7 points |
| 5 cars | 10 points |
| 6 cars | 15 points |
Bonus Points:
- Completed destination tickets: +points shown on ticket
- Incomplete destination tickets: -points (penalty!)
- Longest continuous route: +10 points
The game ends when any player has 2 or fewer trains remaining. Each player gets one final turn, then scores are calculated.
ticket-to-ride/
├── index.html # Main game page
├── css/
│ └── style.css # Game styling
├── js/
│ ├── game.js # Core game logic
│ ├── map-data.js # USA map cities & routes
│ ├── cards.js # Train cards & destination tickets
│ ├── player.js # Player management
│ ├── ai.js # Smart AI opponent
│ ├── scoring.js # Scoring & longest route calculation
│ └── ui.js # UI rendering
└── README.md
- HTML5 Canvas - Map rendering
- Vanilla JavaScript - Game logic (no frameworks)
- CSS3 - Styling and animations
The AI opponent uses strategic decision-making with Dijkstra's pathfinding algorithm.
| Strength | How It Works |
|---|---|
| Path Optimization | Dijkstra finds shortest routes between destination cities |
| Blocking Awareness | Detects bottleneck routes that might be taken by opponents |
| Resource Management | Saves locomotive (wild) cards for when they're needed most |
| Adaptive Strategy | Re-plans routes dynamically when paths get blocked |
| Risk Assessment | Evaluates destination ticket feasibility before committing |
This is a fan-made implementation for educational purposes. Ticket to Ride is a trademark of Days of Wonder, Inc.
Built with Claude Code
