Getting Started
New to ChessHacks? Start with the Platform Overview to
understand the architecture first.
npx chesshacks create, set up your environment:
Environment Setup
- Set up Python environment:
- Install Node.js dependencies:
- Configure environment variables:
.env.template to .env.local in both the root directory and the devtools directory. Fill in:
- Path to your Python environment
- Ports for the backend and frontend (defaults are usually fine)
Running the Development Server
From thedevtools directory, run:
- Starts the Next.js frontend
- Launches the Python backend as a subprocess
- Enables hot reloading for your bot code
Development Workflow
1. Edit Your Bot
Your bot logic lives in/src/main.py. This is where you’ll implement your chess engine.
2. Test in Browser
Open your browser tohttp://localhost:3000 (or your configured port). You’ll see:
- An interactive chess board
- Analysis tools
- The ability to play against your bot
- Real-time move feedback
3. Hot Reloading
When you save changes to files in/src:
- The devtools automatically detect the change
- The Python subprocess restarts
- Your new bot logic is immediately available
- No manual restart needed!
4. View Logs
All logs from both Python files (serve.py and main.py) appear in your Next.js terminal:
stdoutandstderrfrom both processes- Verbose by default for easier debugging
- Real-time updates on bot moves and decisions
Where to Code
Focus your development on/src/main.py - this is your bot’s brain. The other files (serve.py, devtools) handle infrastructure and generally don’t need editing.
Model Training
Important: You should not train your model within this repository.
Manage training separately and import only the trained weights.
Training Architecture
For bots that use machine learning models, we recommend separating your training pipeline from your competition bot repository: Why separate training from deployment?- Training requires large datasets, experiment tracking, and computational resources
- Your competition repo should be lightweight and focused on inference
- Version control for training code and model weights have different needs
- Training environments often have different dependencies than inference
Recommended Workflow
-
Create a separate training repository or folder
- Keep your training scripts, data processing, and experiments separate
- This can be a completely different repository or a dedicated folder in your project
- Add training directories to
.gitignoreif keeping them local
-
Store model weights externally
- Hugging Face Hub (recommended for most models)
- Free hosting for model weights
- Version control for models
- Easy integration with
transformerslibrary
- GitHub Releases (for small models only)
- Suitable for models < 100MB
- Use Git LFS for files between 100MB-2GB
- Other options: Weights & Biases, Google Drive, AWS S3
- Hugging Face Hub (recommended for most models)
-
Fetch weights in your bot
- Download weights during initialization or deployment
- Cache them locally to avoid repeated downloads
- Keep your main repository clean and fast to clone
Example: Using Hugging Face
In your training repository:src/main.py):
Example: Small Models on GitHub
For very small models (< 100MB), you can include them directly:Best Practices
- Document your model source - Include a README explaining where weights come from
- Pin versions - Use specific model versions/commits to ensure reproducibility
- Handle downloads gracefully - Add error handling for network issues
- Consider cold start time - Large model downloads may slow initial deployment
- Test locally first - Ensure weight loading works before deploying
Troubleshooting
Import Errors
If you see:main.py directly. Instead, run the Next.js app which will manage the Python files correctly.
Port Conflicts
If the default ports (3000 for frontend, 5058 for backend) are in use:- Edit your
.env.localfile - Change the port numbers
- Restart the dev server
Python Environment Issues
Make sure:- Your virtual environment is activated
- All dependencies are installed (
pip install -r requirements.txt) - The path in
.env.localpoints to the correct Python executable
Subprocess Not Starting
Check that:- You’re running
npm run devfrom thedevtoolsdirectory - Your
.env.localfile exists and is configured correctly - The Python path in
.env.localis correct
Best Practices
- Keep imports relative in
/src/main.py- they’re designed to work with the subprocess architecture - Use the devtools - don’t run Python files manually
- Check logs frequently - they’re verbose for a reason
- Test edge cases - use the analysis board to test specific positions
- Iterate quickly - take advantage of hot reloading
Next Steps
- Deploy your bot when you’re ready
- Learn about the game format
- Get support if you need help