How emirmurat6606/invertedpendulum works
This is a Pygame inverted-pendulum game with an approximate Q-learning controller and a manual keyboard mode. The main loop initializes the simulation, selects an action (or reads manual input), advances the box-and-pendulum physics, updates the learner, and renders the result; on improved survival time it saves learned weights. The graph includes the documented reward/Q-learning and rendering capabilities. Relationships are limited to calls and data flows shown in excerpts or the README; unsampled details are omitted.
Main entry points: main.py Game Loop · movingbox.py Box Motion · model.py RL Controller · configs.py Game Settings
Components 10
Game Runtime
- Game Loop
main.py
Simulation Physics
- Box Motion
Logic/movingbox.py - Pendulum Dynamics
Logic/pendulum.py
Reinforcement Learning
- RL Controller
Rl/model.py - Q Function
Rl/model.py - Saved Weights
Rl/model_weights.txt
Display and Configuration
- Box View
Interface/movingbox.py - Pendulum View
Interface/pendulum.py - Game Settings
configs.py
Other components
- Player
Connections 15
- Player → Game Loop: starts or controls
README.md - Game Loop → RL Controller: selects and updates
main.py - Game Loop → Box Motion: moves box
main.py - Box Motion → Pendulum Dynamics: updates dynamics
Logic/movingbox.py - Game Loop → RL Controller: passes observed state
main.py - RL Controller → Q Function: evaluates and trains
Rl/model.py - Game Loop → Saved Weights: writes best weights
main.py - Game Loop → Box View: updates and draws
main.py - Game Loop → Pendulum View: draws pendulum
main.py - Box View → Box Motion: reads position
Interface/movingbox.py - Pendulum View → Pendulum Dynamics: renders state
Interface/pendulum.py - Game Loop → Game Settings: reads settings
main.py - Box Motion → Game Settings: reads physics constants
Logic/movingbox.py - Pendulum Dynamics → Game Settings: reads gravity
Logic/pendulum.py - RL Controller → Game Settings: reads screen width
Rl/model.py