How eltaweel1/advanced_tic_tac_toe works
Project type and purpose
• This is a desktop application: an “Advanced Tic Tac Toe” game written in C++ using the Qt framework.
• Purpose: provide a GUI-based tic-tac-toe with user login/registration, AI opponents at multiple difficulties, play-history per user, and two-player mode.
File structure (high-level)
• Top‐level .pro file: Qt project descriptor.
• Core modules (src): ai.{cpp,h}, board.{cpp,h}, gamelogic.{cpp,h}, usermanager.{cpp,h}
• GUI modules (gui): mainwindow.{h,cpp,ui}, loginform, registerform, gamesetupdialog, historydialog
• Data storage (database): users.txt, history.txt under build or root
• Tests: test/test_gamelogic.cpp
Key insights from README
• Project is layered: UI forms, game logic/AI/user management, file-based persistence.
• Tech stack: C++/Qt, OOP, local file system for “database.”
Main components
a. Presentation Layer (GUI)
• LoginForm
• RegisterForm
• MainWindow
• GameSetupDialog
• HistoryDialog
b. Application/Domain Layer
• UserManager (handles login, registration, file I/O for users.txt)
• GameLogic (enforces rules, tracks game state)
• Board (data structure representing the board)
• AI (computes moves based on difficulty)
c. Data Layer (Persistence)
• FileStorage for users (users.txt)
• FileStorage for game history (history.txt)
d. External/Tools
• Qt framework (signals & slots, .ui processing)
• Test suite (test/test_gamelogic.cpp)
Relationships and interactions
• UI → Domain: e.g., MainWindow calls GameLogic to start/advance a game; AI queries Board & GameLogic.
• UI ↔ UserManager: LoginForm/RegisterForm invoke UserManager to authenticate or register users.
• Domain → Data: UserManager reads/writes users.txt; GameLogic or HistoryDialog writes game results to history.txt.
• Data → UI: HistoryDialog reads history.txt via UserManager or a HistoryService.
• All components depend on Qt (for windowing, events, object macros).
Architectural patterns/design principles
• Layered architecture (Presentation → Domain → Data).
• Separation of concerns: UI code (dialogs/windows) is separate from core logic (GameLogic, AI).
• Single Responsibility: each class has one clear purpose (Board = model, UserManager = auth & storage).
• File‐based repository pattern for persistence.