# yess1ne/rl_based_pathfinding architecture

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

- Interactive diagram: https://gitdiagram.com/yess1ne/rl_based_pathfinding
- Repository: https://github.com/yess1ne/rl_based_pathfinding

## Overview

This is a self-running REINFORCE maze-training script. Its workflow is to sample episodes in an 8×8 GridWorld, compute discounted returns, update a policy network, then simulate and print a greedy path. The environment and policy are distinct runtime components; episode collection, return calculation, and updates are internal learning stages. The README documents the intended behavior, while the single source excerpt shows the implementation and call relationships.

Main entry points: [`pathfinding.py`](https://github.com/yess1ne/rl_based_pathfinding/blob/master/pathfinding.py) (Training Loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_environment["Maze Environment"]
  node_world["GridWorld<br/>[pathfinding.py]"]
end

subgraph group_learning["Policy Learning"]
  node_training["Training Loop<br/>[pathfinding.py]"]
  node_policy["Policy Network<br/>[pathfinding.py]"]
  node_episode["Episode Sampling<br/>[pathfinding.py]"]
  node_returns["Return Calculation<br/>[pathfinding.py]"]
  node_update["Policy Update<br/>[pathfinding.py]"]
end

subgraph group_visualization["Path Visualization"]
  node_visualize["Greedy Path Display<br/>[pathfinding.py]"]
end

node_user(("User"))

node_user -->|"runs script"| node_training
node_training -->|"collects episode"| node_episode
node_episode -->|"resets and steps"| node_world
node_episode -->|"samples actions"| node_policy
node_training -->|"computes returns"| node_returns
node_training -->|"updates policy"| node_update
node_update -->|"evaluates and trains"| node_policy
node_training -->|"renders after training"| node_visualize
node_visualize -->|"selects greedy actions"| node_policy
node_visualize -->|"simulates path"| node_world

click node_training "https://github.com/yess1ne/rl_based_pathfinding/blob/master/pathfinding.py"
click node_world "https://github.com/yess1ne/rl_based_pathfinding/blob/master/pathfinding.py"
click node_policy "https://github.com/yess1ne/rl_based_pathfinding/blob/master/pathfinding.py"
click node_episode "https://github.com/yess1ne/rl_based_pathfinding/blob/master/pathfinding.py"
click node_returns "https://github.com/yess1ne/rl_based_pathfinding/blob/master/pathfinding.py"
click node_update "https://github.com/yess1ne/rl_based_pathfinding/blob/master/pathfinding.py"
click node_visualize "https://github.com/yess1ne/rl_based_pathfinding/blob/master/pathfinding.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_world,node_user toneBlue
class node_training,node_policy,node_episode,node_returns,node_update toneAmber
class node_visualize toneMint
```

## Components

### Maze Environment

- [GridWorld](https://github.com/yess1ne/rl_based_pathfinding/blob/master/pathfinding.py): `pathfinding.py`

### Policy Learning

- [Training Loop](https://github.com/yess1ne/rl_based_pathfinding/blob/master/pathfinding.py): `pathfinding.py`
- [Policy Network](https://github.com/yess1ne/rl_based_pathfinding/blob/master/pathfinding.py): `pathfinding.py`
- [Episode Sampling](https://github.com/yess1ne/rl_based_pathfinding/blob/master/pathfinding.py): `pathfinding.py`
- [Return Calculation](https://github.com/yess1ne/rl_based_pathfinding/blob/master/pathfinding.py): `pathfinding.py`
- [Policy Update](https://github.com/yess1ne/rl_based_pathfinding/blob/master/pathfinding.py): `pathfinding.py`

### Path Visualization

- [Greedy Path Display](https://github.com/yess1ne/rl_based_pathfinding/blob/master/pathfinding.py): `pathfinding.py`

### Other components

- **User**

## Connections

- User → Training Loop: runs script (evidence: `pathfinding.py`)
- Training Loop → Episode Sampling: collects episode (evidence: `pathfinding.py`)
- Episode Sampling → GridWorld: resets and steps (evidence: `pathfinding.py`)
- Episode Sampling → Policy Network: samples actions (evidence: `pathfinding.py`)
- Training Loop → Return Calculation: computes returns (evidence: `pathfinding.py`)
- Training Loop → Policy Update: updates policy (evidence: `pathfinding.py`)
- Policy Update → Policy Network: evaluates and trains (evidence: `pathfinding.py`)
- Training Loop → Greedy Path Display: renders after training (evidence: `pathfinding.py`)
- Greedy Path Display → Policy Network: selects greedy actions (evidence: `pathfinding.py`)
- Greedy Path Display → GridWorld: simulates path (evidence: `pathfinding.py`)
