Downloads · 30 days
0
hoangduc102/chess-tournament-model
chess-tournament-model is a machine learning model from hoangduc102. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Hệ thống thi đấu cờ vua với các AI agents sử dụng Minimax và Machine Learning.
Downloads · 30 days
0
Access
Public
Updated Dec 10, 2025
Repo size
3.2 GB
Likes
0
Public
Click a slice to open those files.
.pgn2.6 GB · 82%
From the Hugging Face model README
Hệ thống thi đấu cờ vua với các AI agents sử dụng Minimax và Machine Learning.
Bài tập lớn môn Trí tuệ Nhân tạo (AI) - HCMUT
| Agent | Mô tả | Thuật toán |
|---|---|---|
| Random | Chơi ngẫu nhiên | Random choice |
| Minimax | Tìm kiếm cây trò chơi | Minimax + Alpha-Beta Pruning (depth=3) |
| ML | Học từ 563K positions | Neural Network (PyTorch) |
chess-tournament/
├── main.py # Ứng dụng chính (GUI)
├── agents.py # Định nghĩa các AI agents
├── tournament.py # Quản lý giải đấu
├── ui_components.py # Các component giao diện
├── setup_assets.py # Setup hình ảnh quân cờ
├── requirements.txt # Dependencies
│
├── ml/ # 🤖 Machine Learning Module
│ ├── __init__.py
│ ├── data_processor.py # Xử lý dữ liệu PGN từ Lichess
│ ├── model.py # Neural Network models
│ ├── train.py # Script training
│ └── models/ # Trained models
│ ├── chess_model.pth # PyTorch model (90% accuracy)
│ └── simple_model.npz # Backup model
│
├── data/ # 📦 Dữ liệu
│ ├── pgn/ # File PGN từ Lichess
│ └── processed/ # Dataset đã xử lý
│
├── assets/ # 🎨 Hình ảnh
│ └── img/chess_pieces/ # Hình các quân cờ
│
└── tournaments/ # 📁 Kết quả các giải đấu
pip install -r requirements.txt
python setup_assets.py
python main.py
Cách 1: Tải từ Lichess Database (khuyến nghị)
# Tải file từ https://database.lichess.org/
# Đặt file .pgn.zst vào data/pgn/
# Giải nén bằng Python
python -c "from ml.data_processor import decompress_zst_file; decompress_zst_file('data/pgn/FILE.pgn.zst', 'data/pgn/lichess_games.pgn')"
Cách 2: Tải từ Lichess API (nhanh hơn, ít data hơn)
python ml/train.py --use-api --max-games 3000
# Training với file PGN local
python ml/train.py --pgn data/pgn/lichess_games.pgn --max-games 15000 --min-elo 1800 --epochs 50
hoặc
python ml/train.py --pgn "data/pgn/lichess_games.pgn" --max-games 30000 --min-elo 2000 --epochs 80 --batch-size 512 --model pytorch
# Các options khác
python ml/train.py --help
| Model | Samples | Accuracy | Thời gian |
|---|---|---|---|
| SimpleModel | 563K | 55.5% | ~2 phút |
| ChessNet | 563K | 90.5% | ~15 phút |
| Metric | Kết quả | Yêu cầu |
|---|---|---|
| Win rate | ~95% | ≥ 90% ✅ |
| Metric | Kết quả | Yêu cầu |
|---|---|---|
| Win rate | ~75% | ≥ 60% ✅ |
Thuật toán: Minimax với Alpha-Beta Pruning
Độ sâu: 3 ply
Hàm đánh giá: Material-based
- Tốt: 100, Mã: 320, Tượng: 330
- Xe: 500, Hậu: 900, Vua: 20000
Model: Fully Connected Neural Network
Architecture: 773 → 1024 → 512 → 256 → 128 → 1
Input: Board state (773 features)
- 768: Piece positions (12 types × 64 squares)
- 1: Turn
- 4: Castling rights
Output: Win probability [0, 1]
Training data: 563,284 positions từ Lichess (Elo ≥ 1800)
Framework: PyTorch
Dữ liệu được lấy từ Lichess Database:
lichess_db_standard_rated_2015-07.pgn.zst| Phím | Chức năng |
|---|---|
← → | Nước trước/sau |
Space | Play/Pause |
↑ ↓ | Tăng/giảm tốc độ |
pygame>=2.6.0
python-chess>=1.9.0
numpy>=1.24.0
torch>=2.0.0
requests>=2.28.0
zstandard>=0.21.0
| MSSV | Họ và Tên |
|---|---|
Dự án này được thực hiện cho mục đích học tập tại HCMUT.