How genhavoc/preydictable works
This repository implements a predator–prey grid-world reinforcement-learning pipeline: define and simulate the game, build or estimate transition models, solve and evaluate policies, and train a neural policy with REINFORCE. It also supports dense and sparse kernels and model-free estimation. The README documents the major workflow; source-index references and shown excerpts support some internal calls. Several modules were not sampled, so their finer-grained connections are omitted.
Main entry points: state_space.py State Encoding · transition_engine.py Transition Engine · gradient_estimate.py REINFORCE Gradient · simulator.py Game Simulator
Components 22
Game Environment
- Game Simulator
predator_prey/env/simulator.py - State Encoding
predator_prey/env/state_space.py - Reward Matrix
predator_prey/env/reward_function.py - Transition Engine
predator_prey/env/transition_engine.py - Policy Reward
predator_prey/env/induced_reward.py
Transition Models
- Dense Kernel
predator_prey/core/kernel.py - Sparse Kernel
predator_prey/core/kernel_sparse.py - Estimated Kernel
predator_prey/core/estimate_kernel.py - Policy Kernel
predator_prey/core/induced_kernel.py - Sparse Policy Kernel
predator_prey/core/induced_kernel_sparse.py
Planning and Evaluation
- Value Iteration
predator_prey/algorithms/value_iteration.py - Policy Iteration
predator_prey/algorithms/policy_iteration.py - Greedy Policy
predator_prey/algorithms/induced_policy.py - State Evaluation
predator_prey/core/state_value_eval.py - Sparse Evaluation
predator_prey/core/state_value_eval_sparse.py - Q Evaluation
predator_prey/core/q_value_eval.py
Policy Learning
- Sample Policy
predator_prey/algorithms/sample_policy.py - Neural Policy
predator_prey/algorithms/policy_network.py - REINFORCE Gradient
predator_prey/core/gradient_estimate.py - SGA Optimizer
predator_prey/algorithms/simple_sga.py - Adam Runner
predator_prey/algorithms/run_adam.py
Other components
- RL User
Connections 29
- RL User → Game Simulator: runs game
README.md - Game Simulator → Transition Engine: models dynamics
README.md - Transition Engine → Dense Kernel: builds model
README.md - Transition Engine → Sparse Kernel: builds model
- Game Simulator → Estimated Kernel: samples transitions
predator_prey/core/estimate_kernel.py - State Encoding → Transition Engine: encodes states
predator_prey/env/transition_engine.py - State Encoding → Dense Kernel: encodes states
predator_prey/core/kernel.py - State Encoding → Sparse Kernel: encodes states
predator_prey/core/kernel_sparse.py - State Encoding → Estimated Kernel: encodes samples
predator_prey/core/estimate_kernel.py - RL User → Value Iteration: solves model
README.md - Dense Kernel → Value Iteration: provides kernel
README.md - Dense Kernel → Policy Iteration: provides kernel
README.md - Transition Engine → Policy Iteration: applies matvecs
predator_prey/algorithms/policy_iteration.py - Policy Iteration → Greedy Policy: improves policy
predator_prey/algorithms/policy_iteration.py - Reward Matrix → Sparse Evaluation: provides rewards
predator_prey/core/state_value_eval_sparse.py - Policy Reward → State Evaluation: computes policy reward
predator_prey/core/state_value_eval.py - Policy Reward → Sparse Evaluation: computes policy reward
predator_prey/core/state_value_eval_sparse.py - Policy Kernel → State Evaluation: evaluates transitions
predator_prey/core/state_value_eval.py - Sparse Kernel → Sparse Evaluation: provides sparse model
predator_prey/core/state_value_eval_sparse.py - Sample Policy → Sparse Evaluation: supplies policy
predator_prey/core/state_value_eval_sparse.py - State Encoding → Sample Policy: encodes states
predator_prey/algorithms/sample_policy.py - RL User → Estimated Kernel: estimates model
README.md - Estimated Kernel → Value Iteration: supports planning
README.md - Neural Policy → REINFORCE Gradient: generates actions
predator_prey/core/gradient_estimate.py - Game Simulator → REINFORCE Gradient: runs episodes
predator_prey/core/gradient_estimate.py - REINFORCE Gradient → SGA Optimizer: supplies gradients
predator_prey/algorithms/simple_sga.py - REINFORCE Gradient → Adam Runner: supplies gradients
predator_prey/algorithms/run_adam.py - RL User → REINFORCE Gradient: trains policy
README.md - Value Iteration → Neural Policy: baseline policy