# mahadhsn/java-tic-tac-toe-ai architecture

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

- Interactive diagram: https://gitdiagram.com/mahadhsn/java-tic-tac-toe-ai
- Repository: https://github.com/mahadhsn/java-tic-tac-toe-ai

## Overview

##### Main Components

A. Core Components (Common to both variants):
- Player System (Abstract and Concrete implementations)
- Game Management
- Board Management
- Game Logic

B. Variant-Specific Components:
- 3x3 Implementation
- NxN Implementation
- AI Components

##### Detailed Component Breakdown

Core Components:
**Player (Interface)**
- HumanPlayer
- ComputerPlayer
- SmartComputerPlayer (3x3 only)

**Game (Interface)**
- BasicGame (3x3)
- SmartComputerGame (3x3)
- UpgradedGame (NxN)

**Board (Interface)**
- BasicBoard (3x3)
- UpgradedBoard (NxN)

##### Additional Elements

Annotations for:
- Board size constraints (2 >= N >= 20 for NxN)
- Win condition parameters (M <= N for NxN)
- AI algorithm type (minimax for SmartComputerPlayer)

##### Technical Details

- Maven-managed components
- Test coverage relationship (AppTest)
- Restart functionality connections

## Diagram (Mermaid)

```mermaid
graph TB
    %% Interfaces and Abstract Classes
    Player["Player Interface"]:::interface
    Game["Game Interface"]:::interface
    Board["Board Interface"]:::interface

    %% Player Implementations
    HumanPlayer["Human Player"]:::concrete
    ComputerPlayer["Computer Player"]:::concrete
    SmartComputerPlayer["Smart Computer Player"]:::concrete

    %% 3x3 Implementation
    subgraph ThreeByThree["3x3 Implementation"]
        BasicGame["Basic Game"]:::concrete
        SmartComputerGame["Smart Computer Game"]:::concrete
        BasicBoard["Basic Board"]:::concrete
    end

    %% NxN Implementation
    subgraph NByN["NxN Implementation"]
        UpgradedGame["Upgraded Game"]:::concrete
        UpgradedBoard["Upgraded Board"]:::concrete
        note["2 >= N >= 20<br/>Win condition: M <= N"]:::note
    end

    %% Additional Components
    Restart["Restart Functionality"]:::utility
    AppTest["App Test"]:::test

    %% Relationships
    Player --> HumanPlayer
    Player --> ComputerPlayer
    Player --> SmartComputerPlayer
    Game --> BasicGame
    Game --> SmartComputerGame
    Game --> UpgradedGame
    Board --> BasicBoard
    Board --> UpgradedBoard

    BasicGame --> BasicBoard
    SmartComputerGame --> BasicBoard
    SmartComputerGame --> SmartComputerPlayer
    UpgradedGame --> UpgradedBoard

    %% Click Events
    click Player "https://github.com/mahadhsn/Java-Tic-Tac-Toe-AI/blob/main/3x3-TicTacToe/src/main/java/jar/Player.java"
    click Game "https://github.com/mahadhsn/Java-Tic-Tac-Toe-AI/blob/main/3x3-TicTacToe/src/main/java/jar/Game.java"
    click Board "https://github.com/mahadhsn/Java-Tic-Tac-Toe-AI/blob/main/3x3-TicTacToe/src/main/java/jar/Board.java"
    click HumanPlayer "https://github.com/mahadhsn/Java-Tic-Tac-Toe-AI/blob/main/3x3-TicTacToe/src/main/java/jar/HumanPlayer.java"
    click ComputerPlayer "https://github.com/mahadhsn/Java-Tic-Tac-Toe-AI/blob/main/3x3-TicTacToe/src/main/java/jar/ComputerPlayer.java"
    click SmartComputerPlayer "https://github.com/mahadhsn/Java-Tic-Tac-Toe-AI/blob/main/3x3-TicTacToe/src/main/java/jar/SmartComputerPlayer.java"
    click BasicGame "https://github.com/mahadhsn/Java-Tic-Tac-Toe-AI/blob/main/3x3-TicTacToe/src/main/java/jar/BasicGame.java"
    click SmartComputerGame "https://github.com/mahadhsn/Java-Tic-Tac-Toe-AI/blob/main/3x3-TicTacToe/src/main/java/jar/SmartComputerGame.java"
    click BasicBoard "https://github.com/mahadhsn/Java-Tic-Tac-Toe-AI/blob/main/3x3-TicTacToe/src/main/java/jar/BasicBoard.java"
    click UpgradedGame "https://github.com/mahadhsn/Java-Tic-Tac-Toe-AI/blob/main/NxN-TicTacToe/src/main/java/jar/UpgradedGame.java"
    click UpgradedBoard "https://github.com/mahadhsn/Java-Tic-Tac-Toe-AI/blob/main/NxN-TicTacToe/src/main/java/jar/UpgradedBoard.java"
    click Restart "https://github.com/mahadhsn/Java-Tic-Tac-Toe-AI/blob/main/3x3-TicTacToe/src/main/java/jar/Restart.java"
    click AppTest "https://github.com/mahadhsn/Java-Tic-Tac-Toe-AI/blob/main/3x3-TicTacToe/src/test/java/jar/AppTest.java"

    %% Styles
    classDef interface fill:#FFE873,stroke:#333,stroke-width:2px;
    classDef concrete fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef utility fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef test fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef note fill:#fff,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5;

    %% Legend
    subgraph Legend
        L1["Interface"]:::interface
        L2["Concrete Class"]:::concrete
        L3["Utility"]:::utility
        L4["Test"]:::test
    end
```
