Loading repository data…
Loading repository data…
lephgvu / repository
Othello AI Agent is a research and practice project in artificial intelligence, focusing on building automated Othello (Reversi) playing agents using both classical AI and deep learning.
Dự án này xây dựng các tác nhân (Agent) chơi cờ Othello tự động sử dụng hai phương pháp: <<<<<<< HEAD
=======
42ee39ede7ce3d7787f98ded6fb11a5afa0d7172 ⚠️ Lưu ý quan trọng: Dự án sử dụng TensorFlow, yêu cầu Python 3.10. Vui lòng cài đặt đúng phiên bản Python này để tránh xung đột thư viện.
Để chạy chương trình không bị lỗi, vui lòng giữ nguyên cấu trúc thư mục như sau:
Othello_Project/
│
├── demo_cnn.py # Chạy demo trực quan: CNN vs Random
├── evaluate_ml.py # Đánh giá hiệu suất: CNN vs Random (100 ván)
├── game.py # Chạy game cổ điển: Minimax vs Random
├── minimax.py # Thuật toán Minimax (Expert Agent)
├── randomMove.py # Thuật toán Random (đối thủ ngẫu nhiên)
├── solution.py # Class cha (Algorithm Base)
│
├── CNNAgent/ # [Module] Chứa mã nguồn Deep Learning
│ ├── __init__.py
│ ├── agent.py # Logic xử lý nước đi của CNN Agent
│ ├── model.py # Kiến trúc mạng CNN
│ ├── train.py # Script huấn luyện
│ ├── dataset.py # Script sinh dữ liệu
│ ├── utils.py # Các hàm tiện ích xử lý bàn cờ
│ ├── othello_dataset.npz # (Tự sinh ra sau bước tạo data)
│ └── cnn_feat_othello.h5 # (Tự sinh ra sau khi train xong)
│
└── GameUI_Logic/ # Thư viện đồ họa và logic game
Bạn cần cài đặt các thư viện cần thiết. Khuyên dùng Miniconda để quản lý môi trường ảo.
Cách 1: Sử dụng Miniconda (Khuyên dùng)
conda create -n tf310 python=3.10
conda activate tf310
pip install tensorflow scikit-learn numpy tqdm matplotlib
Cách 2: Sử dụng Virtualenv (Venv)
python -m venv venv
venv\Scripts\activate
source venv/bin/activate
pip install tensorflow scikit-learn numpy tqdm matplotlib
Lưu ý: Luôn mở Terminal tại thư mục gốc của dự án (nơi chứa file game.py).
Để xem Minimax (độ sâu 4) đấu với máy Random:
python game.py
Quy trình gồm 3 bước: Sinh dữ liệu -> Huấn luyện -> Chạy thử.
<<<<<<< HEAD
Dùng dữ liệu vừa tạo để huấn luyện mạng CNN. Lệnh này sẽ tạo file model CNNAgent/cnn_feat_othello.h5.
python -m CNNAgent.train
python demo_cnn.py
======= Trong dự án này đã chạy sẵn 2 bước đầu, bạn có thể chạy ngay bước 3 nếu muốn.
Cho Minimax tự chơi với Random để tạo dữ liệu học. Lệnh này sẽ tạo file CNNAgent/othello_dataset.npz.
python -m CNNAgent.dataset
Dùng dữ liệu vừa tạo để huấn luyện mạng CNN. Lệnh này sẽ tạo file model CNNAgent/cnn_feat_othello.h5.
python -m CNNAgent.train
python demo_cnn.py
42ee39ede7ce3d7787f98ded6fb11a5afa0d7172
python evaluate_ml.py