A modern web implementation of Bagh Chal (Tigers and Goats), a traditional asymmetric strategy board game from Nepal. Play online with real-time multiplayer functionality.
Bagh Chal is a two-player strategy game where:
- 4 Tigers hunt and capture goats by jumping over them
- 20 Goats try to block all tiger movements to win
- Tigers win by capturing 5 goats
- Goats win by immobilizing all tigers
- Django 5.2.4 - Web framework
- Django Channels - WebSocket support for real-time gameplay
- Django REST Framework - API endpoints
- SQLite - Database (development)
- React 19 - UI library
- Vite - Build tool and dev server
- Tailwind CSS 4 - Styling
- React Router 7 - Client-side routing
- Axios - HTTP client
- Python 3.8+
- Node.js 18+
- npm or yarn
# Navigate to backend directory
cd backend
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Run migrations
python manage.py migrate
# Create superuser (optional)
python manage.py createsuperuser
# Start development server
python manage.py runserverBackend runs on http://localhost:8000
# Navigate to frontend directory
cd frontend
# Install dependencies
npm install
# Start development server
npm run dev
Frontend runs on http://localhost:5173
Start a Game: Create a new game and share the ID with a friend Join an existing game using a game ID Use Quick Match to find an opponent
Placement Phase: Goat player places one goat per turn on any empty intersection Tiger player can move or capture goats
Movement Phase: After all 20 goats are placed, goats can now move Both players move strategically to achieve their win condition
Winnng:
Tigers win: Capture 5 goats
Goats win: Block all tiger movements
For detailed rules, visit the in-game Rules page
baghchal/
├── backend/
│ ├── backend/ # Django project settings
│ ├── baghchal/ # Game logic app
│ │ ├── core/ # Game state management
│ │ ├── consumers.py # WebSocket handlers
│ │ ├── routing.py # WebSocket URL routing
│ │ └── views.py # HTTP views
│ ├── core/ # User management app
│ └── manage.py
│
└── frontend/
├── src/
│ ├── components/ # Reusable UI components
│ ├── routes/ # Page components
│ ├── context/ # React context (Auth, WebSocket)
│ └── assets/ # Images and static files
└── package.json
- Real-time Multiplayer - WebSocket-based game synchronization
- Multiple Game Modes:
- Create private game with custom ID
- Join existing game
- Quick match (auto-matching)
- Guest Play - No account required
- User Accounts - Optional registration for tracking stats
- Move Validation - Server-side game rule enforcement
- Responsive Design - Works on desktop and mobile
Frontend (frontend/.env):
VITE_BASE_WS_URL=ws://localhost:8000/ws/game/
VITE_BASE_HTTP_URL=http://localhost:8000/Backend (backend/backend/settings.py):
- Debug mode: Set
DEBUG = Truefor development - Allowed hosts: Update
ALLOWED_HOSTSfor production - CORS: Configure
CORS_ALLOWED_ORIGINS
# Backend tests
cd backend
python manage.py test
# Frontend tests (when implemented)
cd frontend
npm test# Frontend linting
cd frontend
npm run lintThe game engine is split between frontend and backend:
- Frontend (
MoveValidation.js): Client-side move validation for instant feedback - Backend (
baghchal/core/utils.py): Authoritative game state and validation - WebSocket (
consumers.py): Real-time state synchronization
waiting- Waiting for second playerongoing- Game in progressover- Game completed
placement- Goats being placed on board (first 20 moves)displacement- Both players moving pieces
We welcome contributions! Here's how to get started:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Test thoroughly
- Commit (
git commit -m 'Add amazing feature') - Push (
git push origin feature/amazing-feature) - Sync your Fork with main repo
- Open a Pull Request
- Game statistics and leaderboards
- AI opponent (minimax preferably)
- Sound effects and animations
- Spectator mode
- Game replay functionality
POST /signup/- User registrationPOST /login/- User authenticationGET /- API health check
The backend supports authentication using Google OAuth.
This endpoint handles both login and signup automatically based on the user's email.
- URL:
/google-auth/ - Method:
POST
{
"token": "<google_id_token>"
}The following environment variable is required for Google OAuth authentication:
GOOGLE_CLIENT_ID=_your_google_client_id_ws://localhost:8000/ws/game/?game_id={id}&mode={mode}&username={user}mode:create,join,quick,rejoinplay_as:tigerorgoat(optional)
This project supports authentication using Google OAuth.
GOOGLE_CLIENT_ID(required): Google OAuth client ID from Google Cloud Console.
- URL:
/api/auth/google - Method:
GET
Initiates the Google OAuth login flow. Redirects the user to Google for authentication and then back to the application after successful login.
- No request body required.
GET /api/auth/googleThis section helps developers quickly understand and integrate Google OAuth authentication.
This project is open source and available under the MIT License.
For questions or suggestions, please open an issue on GitHub.