# tomas-dorado/reto-algoritmo architecture

> Architecture diagram of the GitHub repository tomas-dorado/reto-algoritmo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tomas-dorado/reto-algoritmo
- Repository: https://github.com/tomas-dorado/reto-algoritmo

## Overview

The project is divided into two main algorithmic modules – one for solving knight movement sequences (in the "Caballos" folder) and another for solving the N-Reinas (N-Queens) problem (in the "Reinas" folder). There are also a couple of utility files (like main.py and menu.py) that likely serve as central launchers or navigational elements for the overall project.

##### Main Components
- Caballos Module
- Components: Caballo.py (core knight movement computation with dynamic programming), Nodo.py (if used for representing a state or step), Simulador.py (for simulating movement sequences), lanzador.py (entry point for calculating knight movement sequences), and any common utility initialization in __init__.py.
- Reinas Module
- Common/Global Components
- main.py and menu.py likely provide an interface for users to select which module to run.
- requirements.txt lists Python dependencies, and __pycache__ folders are for Python’s compiled files (not part of the logical architecture).

##### Relationships and Interactions
- Both modules (“Caballos” and “Reinas”) operate as self-contained algorithmic solutions. They share similar entry point patterns (each having a lanzador.py) which triggers the computational process (dynamic programming in one, backtracking in the other).
- The main.py and menu.py files should be represented as the application’s control layer that allows a user to choose which algorithm to run.
- In each module, the core algorithm files (e.g., Caballo.py/Simulador.py and Reina.py/Visualizar.py) interact with supporting classes (Nodo.py) and follow specific algorithmic flows (recursion/dynamic programming in Caballos; backtracking in Reinas).

##### Architectural Patterns
- For Caballos:
- The solution is built using recursion with a dynamic programming element (caching sub-problem results to avoid recomputation). Represent the recursive function calls and the movement validation flow.
- For Reinas:
- The implementation employs a backtracking algorithm using a state represented as nodes (Nodo.py) and a queen checker (Reina.py). Also, there’s a visualization component (Visualizar.py) that maps the computed solution to a human-readable board.
- Both modules follow a modular design with a clear separation of concerns: computation logic is abstracted away from the user interface or launcher components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Reto-algoritmo Project"]:::global

    subgraph "User Interface / Control"
        UI1["main.py"]:::global
        UI2["menu.py"]:::global
    end

    subgraph "Caballos Module (Knight Movements)" 
        C1["lanzador.py"]:::caballos
        C2["CaballoAjedrez (Caballo.py)"]:::caballos
        C3["Nodo (State Representation)"]:::caballos
        C4["Simulador (Movement Simulation)"]:::caballos
    end

    subgraph "Reinas Module (N-Queens)"
        R1["lanzador.py"]:::reinas
        R2["Reina (Queen Logic)"]:::reinas
        R3["Nodo (Backtracking State)"]:::reinas
        R4["Visualizar (Board Visualization)"]:::reinas
    end

    %% Connections from the project to UI and modules
    A --> UI1
    A --> UI2
    A --> C1
    A --> R1

    %% Caballos Module flow
    C1 -->|"calls"| C2
    C2 -->|"updates"| C3
    C1 -->|"uses"| C4

    %% Reinas Module flow
    R1 -->|"initiates"| R2
    R1 -->|"builds state"| R3
    R1 -->|"renders"| R4

    %% UI control directing to module launchers
    UI1 -->|"selects Caballos"| C1
    UI1 -->|"selects Reinas"| R1
    UI2 -->|"navigates to Caballos"| C1
    UI2 -->|"navigates to Reinas"| R1

    %% Click Events for Caballos Module Components
    click C2 "https://github.com/tomas-dorado/reto-algoritmo/blob/main/Caballos/Caballo.py"
    click C3 "https://github.com/tomas-dorado/reto-algoritmo/blob/main/Caballos/Nodo.py"
    click C4 "https://github.com/tomas-dorado/reto-algoritmo/blob/main/Caballos/Simulador.py"
    click C1 "https://github.com/tomas-dorado/reto-algoritmo/blob/main/Caballos/lanzador.py"

    %% Click Events for Reinas Module Components
    click R2 "https://github.com/tomas-dorado/reto-algoritmo/blob/main/Reinas/Reina.py"
    click R3 "https://github.com/tomas-dorado/reto-algoritmo/blob/main/Reinas/Nodo.py"
    click R4 "https://github.com/tomas-dorado/reto-algoritmo/blob/main/Reinas/Visualizar.py"
    click R1 "https://github.com/tomas-dorado/reto-algoritmo/blob/main/Reinas/lanzador.py"

    %% Click Events for UI Components
    click UI1 "https://github.com/tomas-dorado/reto-algoritmo/blob/main/main.py"
    click UI2 "https://github.com/tomas-dorado/reto-algoritmo/blob/main/menu.py"

    %% Styles
    classDef caballos fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef reinas fill:#d4edda,stroke:#333,stroke-width:2px;
    classDef global fill:#fff3cd,stroke:#333,stroke-width:2px;
```
