# corentineuvrard/tic-tac-toe architecture

> Architecture diagram of the GitHub repository corentineuvrard/tic-tac-toe, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/corentineuvrard/tic-tac-toe
- Repository: https://github.com/corentineuvrard/tic-tac-toe

## Overview

##### Project type and purpose
- This is a small, self-contained OCaml application implementing Tic-tac-toe with an AI opponent using the minimax algorithm.
- It’s structured more like a classic CLI/game engine than a client-server or web app.

##### File structure
- Top-level files correspond almost one-to-one with logical modules:
- ai.ml        → the AI engine (minimax implementation)
- drawings.ml  → presentation layer (text or ASCII “view”)
- functions.ml → core game rules and utility functions (move generation, winner detection, board evaluation)
- variables.ml → game state representation (board data structures, players, constants)
- tic_tac_toe.ml → main controller and game loop orchestrator
- makefile     → build and run scripts

##### README for additional insights
- Confirms the use of minimax, hints at possible alpha–beta pruning—i.e., a future optimization of the search algorithm layer (AI module).

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User"]:::external
    subgraph "Controller"
        CTRL["tic_tac_toe.ml\n(Controller)"]:::controller
    end
    subgraph "View"
        VIEW["drawings.ml\n(View)"]:::view
    end
    subgraph "Model"
        VAR["variables.ml\n(State)"]:::model
        FUNC["functions.ml\n(Logic)"]:::model
    end
    subgraph "AI Engine"
        AI["ai.ml\n(AI Engine)"]:::ai
    end
    subgraph "Build System"
        MAKE["Makefile"]:::build
    end

    User -->|User Input| CTRL
    CTRL -->|draw_board| VIEW
    CTRL -->|apply_move| FUNC
    CTRL -->|get_state| VAR
    CTRL -->|get_best_move| AI
    AI -->|evaluate_positions| FUNC
    FUNC -->|access_state| VAR
    VAR -->|updated_state| CTRL
    MAKE -.->|build/run| CTRL

    click AI "https://github.com/corentineuvrard/tic-tac-toe/blob/master/ai.ml"
    click VIEW "https://github.com/corentineuvrard/tic-tac-toe/blob/master/drawings.ml"
    click CTRL "https://github.com/corentineuvrard/tic-tac-toe/blob/master/tic_tac_toe.ml"
    click VAR "https://github.com/corentineuvrard/tic-tac-toe/blob/master/variables.ml"
    click FUNC "https://github.com/corentineuvrard/tic-tac-toe/blob/master/functions.ml"
    click MAKE "https://github.com/corentineuvrard/tic-tac-toe/tree/master/makefile"

    classDef view fill:#cce5ff,stroke:#3399ff;
    classDef controller fill:#ffe5cc,stroke:#ff9933;
    classDef model fill:#e5ffcc,stroke:#33cc33;
    classDef ai fill:#e5ccff,stroke:#9933ff;
    classDef build fill:#f2f2f2,stroke:#b3b3b3,stroke-dasharray:5 5;
    classDef external fill:#ffffff,stroke:#000000,stroke-dasharray:2 2;
```
