# shashkat/maze-solver-with-reinforcement-learning architecture

> Architecture diagram of the GitHub repository shashkat/maze-solver-with-reinforcement-learning, 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/shashkat/maze-solver-with-reinforcement-learning
- Repository: https://github.com/shashkat/maze-solver-with-reinforcement-learning

## Overview

##### Project type and purpose
- It reads predefined grids and position lists from CSV files, runs a Q-learning loop, updates a Q-table, and hands off results to an R script for plotting.

##### File structure
- Top-level files:
- grid.csv, all_positions.csv – input data defining the maze layout and valid states
- functions.py – helper routines for state transitions, rewards, Q-table updates
- q_learning.py – main driver: loads data, sets hyperparameters, runs training loops, saves intermediate snapshots
- plot_images.R – reads the CSV snapshots, uses tidyverse/gganimate to build GIFs in the images/ folder
- images/ – output folder for generated GIFs
- plot_images.R, LICENSE, README.md – ancillary documentation/config

##### README for additional insights
- Key hyperparameters (num_episodes, gamma, epsilon, episodes_and_next_10_to_plot) are configured in q_learning.py.
- Dependencies: Python (numpy, pandas, random, tqdm) and R (tidyverse, ggplot2, reshape2, glue, gganimate).
- No external services—fully local.

- Inputs (e.g., light blue rectangles)
- Processing modules (e.g., green)
- Outputs (e.g., orange)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Input Data Layer"
        A["grid.csv"]:::input
        B["all_positions.csv"]:::input
    end

    subgraph "Q-Learning Engine"
        C["functions.py"]:::processing
        D["q_learning.py (hyperparams, loop)"]:::processing
    end

    subgraph "Data Store"
        E[(CSV Snapshots)]:::datastore
    end

    subgraph "Visualization Engine"
        F["plot_images.R"]:::processing
    end

    subgraph "Output Artifacts"
        G["images/ (GIFs)"]:::output
    end

    A -->|reads| D
    B -->|reads| D
    C -->|used by| D
    D -->|writes snapshots| E
    E -->|reads snapshots| F
    F -->|generates| G

    click A "https://github.com/shashkat/maze-solver-with-reinforcement-learning/blob/main/grid.csv"
    click B "https://github.com/shashkat/maze-solver-with-reinforcement-learning/blob/main/all_positions.csv"
    click C "https://github.com/shashkat/maze-solver-with-reinforcement-learning/blob/main/functions.py"
    click D "https://github.com/shashkat/maze-solver-with-reinforcement-learning/blob/main/q_learning.py"
    click F "https://github.com/shashkat/maze-solver-with-reinforcement-learning/blob/main/plot_images.R"
    click G "https://github.com/shashkat/maze-solver-with-reinforcement-learning/tree/main/images/"

    classDef input fill:#ccf,stroke:#333,stroke-width:1px
    classDef processing fill:#cfc,stroke:#333,stroke-width:1px
    classDef datastore fill:#ffeb99,stroke:#333,stroke-width:1px
    classDef output fill:#f9c,stroke:#333,stroke-width:1px
```
