# joseangelbmt/othello_intelligent_agents architecture

> Architecture diagram of the GitHub repository joseangelbmt/othello_intelligent_agents, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joseangelbmt/othello_intelligent_agents
- Repository: https://github.com/joseangelbmt/othello_intelligent_agents

## Overview

##### Main Components
- User Interface Layer:
- Represented by MainGame.py and Interface.py.
- Game Logic and Rules:
- GameRules.py contains the core rules of Othello.
- Node.py and possibly Prueba.py relate to representing game states or might be used for test/debug purposes.
- Intelligent Agents:
- Agent.py includes classes implementing the different intelligent agents, including those using the Alpha-Beta pruning and MCTS algorithms.
- Evaluation Module:
- Evaluator.py is responsible for evaluating moves. It is specifically tied to the Alpha-Beta agent through the use of a weight matrix.
- Evolutionary Algorithm:
- Genetic.py implements the genetic algorithm for optimizing evaluation weights.
- AGCHC.txt is the output file where the results from the genetic computation (weight matrices, fitness evolution, execution times) are stored.
- Simulation and Data Logging:
- Simulation.py lets you run automated game simulations.
- othello.csv stores the outcomes and studies from these simulations.
- External Dependencies and Setup:
- The requirements.txt file shows the external libraries or dependencies.
- Any IDE/project configuration (e.g., .idea folder) can be noted as supporting infrastructure.

##### Relationships and Interactions
- The user launches the project through MainGame.py, which invokes the graphical user interface (Interface.py).
- The interface leads to player selection and determines which intelligent agents (from Agent.py) will play.
- During gameplay, game rules (GameRules.py) and state handling (Node.py) are used to progress the game.
- Agents make decisions using their specific strategies:
- The Alpha-Beta agent uses Evaluator.py for evaluating game positions.
- The MCTS agent uses predetermined iterations (modifiable through “selectPlayers” in MainGame.py).
- The genetic algorithm (Genetic.py) may run independently to optimize the weight matrix, outputting results to AGCHC.txt.
- Simulation.py is a specialized module for creating game simulations and logs outcomes to othello.csv.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Distinct modules for UI, game logic, AI agents, evaluation, evolutionary computation, and simulation.
- Modularity: Each file represents a core component that can be independently modified or replaced.
- Configurability: Parameters like evaluator weights and MCTS iterations can be tuned in the controller logic of MainGame.py and within respective module constructors.
- Data Flow: User interactions flow from the UI into game mechanics and agent decision-making, while evolutionary optimization and simulation log their results to external files.

## Diagram (Mermaid)

```mermaid
graph TD
    %% User Interface Layer
    subgraph "User Interface"
        UI1["MainGame.py"]:::ui
        UI2["Interface.py"]:::ui
    end

    %% Game Engine with Rules and State
    subgraph "Game Engine"
        GE1["GameRules.py"]:::game
        GE2["Node.py"]:::game
        GE3["Prueba.py"]:::game
    end

    %% Intelligent Agents
    IA["Agent.py"]:::agents

    %% Evaluation Module
    EM["Evaluator.py"]:::evaluator

    %% Genetic Algorithm Module
    subgraph "Genetic Algorithm Module"
        GA1["Genetic.py"]:::genetic
        GA2["AGCHC.txt"]:::genetic
    end

    %% Simulation Module
    subgraph "Simulation Module"
        SM1["Simulation.py"]:::sim
        SM2["Results Data Store (othello.csv)"]:::sim
    end

    %% External Dependencies and Setup
    subgraph "External Dependencies"
        EX1["requirements.txt"]:::external
        EX2[".idea"]:::external
    end

    %% Relationships and Data Flow
    UI1 -->|"start_game"| GE1
    GE1 -->|"init_game"| IA
    IA -->|"AlphaBetaUses"| EM
    GA1 -->|"OptimizedWeights"| EM
    SM1 -->|"LogsData"| SM2

    %% Click Events for User Interface Layer
    click UI1 "https://github.com/joseangelbmt/othello_intelligent_agents/blob/master/MainGame.py"
    click UI2 "https://github.com/joseangelbmt/othello_intelligent_agents/blob/master/Interface.py"

    %% Click Events for Game Engine
    click GE1 "https://github.com/joseangelbmt/othello_intelligent_agents/blob/master/GameRules.py"
    click GE2 "https://github.com/joseangelbmt/othello_intelligent_agents/blob/master/Node.py"
    click GE3 "https://github.com/joseangelbmt/othello_intelligent_agents/blob/master/Prueba.py"

    %% Click Event for Intelligent Agents
    click IA "https://github.com/joseangelbmt/othello_intelligent_agents/blob/master/Agent.py"

    %% Click Event for Evaluation Module
    click EM "https://github.com/joseangelbmt/othello_intelligent_agents/blob/master/Evaluator.py"

    %% Click Events for Genetic Algorithm Module
    click GA1 "https://github.com/joseangelbmt/othello_intelligent_agents/blob/master/Genetic.py"
    click GA2 "https://github.com/joseangelbmt/othello_intelligent_agents/blob/master/AGCHC.txt"

    %% Click Events for Simulation Module
    click SM1 "https://github.com/joseangelbmt/othello_intelligent_agents/blob/master/Simulation.py"
    click SM2 "https://github.com/joseangelbmt/othello_intelligent_agents/blob/master/othello.csv"

    %% Click Events for External Dependencies and Setup
    click EX1 "https://github.com/joseangelbmt/othello_intelligent_agents/blob/master/requirements.txt"
    click EX2 "https://github.com/joseangelbmt/othello_intelligent_agents/blob/master/.idea"

    %% Styles
    classDef ui fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
    classDef game fill:#ccffcc,stroke:#009900,stroke-width:2px;
    classDef agents fill:#ccccff,stroke:#0000cc,stroke-width:2px;
    classDef evaluator fill:#ffffcc,stroke:#cccc00,stroke-width:2px;
    classDef genetic fill:#ffccff,stroke:#cc00cc,stroke-width:2px;
    classDef sim fill:#ccffff,stroke:#00cccc,stroke-width:2px;
    classDef external fill:#f0f0f0,stroke:#999999,stroke-width:2px;
```
