This repository started as a side project that grew out of a joint
project at TAVE, an inter-university IT association. It is a small Pygame
desktop app (540x960) where you play Connect-4 against
reinforcement-learning AIs at three difficulty levels. All inference
runs through ONNX Runtime; the original PyTorch training code lives
under before_onnx/.
Current version: 1.0.2 (see ver in game.py).
For the full development write-up (project process, training notes, etc.), see the Notion page: pygame project notes.
- Download the latest zip from the Releases tab on GitHub and
extract it. Run the
ConnectX_*.exefile inside. - If Microsoft Defender SmartScreen blocks the launch with the "Windows의 PC 보호" / "Windows protected your PC" dialog, click 추가 정보 (More info) and then 실행 (Run anyway).
intro() in game.py provides:
new game- pickeasy/normal/hardand playcontinue- resume fromfiles/continue.pklhow to- in-app tutorialreview- replay the last finished game fromfiles/review.pklinfo- app infosetting- first player, piece colors, music / SFX volumes
All three difficulties run through ONNX Runtime in
test_model.py. easy and normal actually share the
same backbone weights; only the inference strategy differs.
easy- Minimax Double-DQN (ResNet) trained with self-play. The 7x7 Q-output is read as a(my move, opponent move)payoff and picked with a one-step minimax.normal- Same DDQN aseasy, but used as the prior for an AlphaGo-style MCTS (200 sims). A small auxiliary value network (value_model.onnx) contributes 10% to leaf evaluations.hard- AlphaZero ResNet (joint policy + value head) trained via iterative self-play, driving an AlphaZero MCTS (100 sims).
PyTorch model definitions live in before_onnx/models.py and before_onnx/pt2onnx.py re-exports them to ONNX.
- game.py - Pygame entry point, menus, play loop, animations
- classes.py -
Button, color palette, sound assets, easter-eggee_boards - functions.py - save / load (setting, record, continue, review), board rendering helpers, win check
- env.py -
ConnectFourgame logic, MCTS nodes,MCTS,MCTS_alphago - test_model.py - difficulty-aware ONNX inference
entry point (
test_main) - before_onnx/ - PyTorch model definitions and ONNX export script
files/- models (.onnx), sounds, images, fonts, saved data (.pkl)
These files in files/ are created and updated automatically as you
play:
continue.pkl- in-progress game forcontinuereview.pkl- last finished game forreviewrecord.pkl- per-difficulty win / draw / loss totalssetting.pkl/default_setting.pkl- user settings
Sound and icon source URLs are listed inline in classes.py and in files/sources.txt.





