Skip to main content

PPOConfig

The PPOConfig dataclass defines all configuration parameters for PPO reinforcement learning training and the CL1 neural hardware interface.

Environment Configuration

str
default:"progressive_deathmatch.cfg"
Path to the VizDoom configuration file that defines the game scenario
str
default:"RES_320X240"
Screen resolution for the DOOM game buffer. Valid values are VizDoom resolution constants like RES_320X240, RES_640X480
bool
default:"true"
Whether to enable the screen buffer for visual observations
float
default:"360.0"
Maximum absolute degrees for TURN_LEFT_RIGHT_DELTA action
float
default:"30.0"
Discrete turn step size in degrees when using turn buttons
float
default:"3.0"
Initial standard deviation (in degrees) for camera delta distribution
bool
default:"false"
Toggle for single categorical action space vs. combinatorial action space

Neural Interface - Channel Configuration

int
default:"64"
Total number of channels available on the CL1 hardware
List[int]
default:"[8, 9, 10, 17, 18, 25, 27, 28, 57]"
Channel indices used for encoding game state into stimulation patterns
List[int]
default:"[41, 42, 49]"
Channel indices that decode to forward movement actions
List[int]
default:"[50, 51, 58]"
Channel indices that decode to backward movement actions
List[int]
default:"[13, 14, 21]"
Channel indices that decode to strafe left actions
List[int]
default:"[45, 46, 53]"
Channel indices that decode to strafe right actions
List[int]
default:"[29, 30, 31, 37]"
Channel indices that decode to turn left actions
List[int]
default:"[59, 60, 61, 62]"
Channel indices that decode to turn right actions
List[int]
default:"[32, 33, 34]"
Channel indices that decode to attack/fire actions

Stimulation Design Parameters

Parameters used to construct cl.StimDesign objects for biphasic electrical stimulation.
float
default:"160.0"
Duration of the first (negative) phase in microseconds (μs)
float
default:"160.0"
Duration of the second (positive) phase in microseconds (μs)
float
default:"1.0"
Minimum stimulation amplitude in microamps (μA). Used as the magnitude for phase1 (negative)
float
default:"2.5"
Maximum stimulation amplitude in microamps (μA). Used as the magnitude for phase2 (positive)

Burst Design Parameters

Parameters used to construct cl.BurstDesign objects that define stimulation frequency and duration.
float
default:"4.0"
Minimum burst frequency in Hertz (Hz)
float
default:"40.0"
Maximum burst frequency in Hertz (Hz)
int
default:"500"
Number of pulses per burst. Set to 500 to ensure stimulation lasts between game ticks

PPO Hyperparameters

float
default:"3e-4"
Learning rate for the Adam optimizer
float
default:"0.99"
Discount factor for future rewards
float
default:"0.95"
Lambda parameter for Generalized Advantage Estimation (GAE)
float
default:"0.2"
Clipping parameter for PPO policy updates
float
default:"0.3"
Coefficient for value function loss in the total loss
float
default:"0.02"
Coefficient for entropy bonus to encourage exploration
float
default:"3"
Maximum gradient norm for gradient clipping. Can be reduced to 1 or 0.5 for more conservative updates
bool
default:"true"
Whether to normalize returns for critic training. Stabilizes the critic but may affect learning dynamics

Training Configuration

int
default:"1"
Number of parallel environments to run
int
default:"2048"
Number of environment steps to collect per policy update (per environment)
int
default:"256"
Minibatch size for PPO updates
int
default:"4"
Number of epochs to train on each batch of collected experience
int
default:"2000"
Maximum number of episodes to train for
bool
default:"true"
Whether to use CL1 hardware or run in simulation mode

Network Architecture

int
default:"128"
Hidden layer size for encoder, decoder, and value networks

Logging and Checkpointing

str
default:"checkpoints/l5_2048_rand/logs"
Directory for TensorBoard logs
str
default:"checkpoints/l5_2048_rand"
Directory for saving model checkpoints
int
default:"100"
Save checkpoint every N episodes
int
default:"50"
Evaluate policy every N episodes

Reward Shaping

float
default:"1"
Reward threshold above which positive feedback is triggered. Requires tuning
float
default:"-1"
Reward threshold below which negative feedback is triggered. Requires tuning
float
default:"1000.0"
Terminal reward bonus for armor-related objectives. Requires tuning
float
default:"2.5"
Gain multiplier for aim alignment reward shaping
float
default:"250.0"
Maximum distance at which aim alignment reward is computed
float
default:"2.5"
Bonus reward for accurate aim alignment
float
default:"4.0"
Angle threshold in degrees for aim alignment bonus
float
default:"0.01"
Scaling factor for movement velocity rewards
bool
default:"true"
Use simplified reward function. When false, factors in manually shaped aim alignment and velocity rewards

Feedback Stimulation - Step-level Rewards

float
default:"2.0"
Stimulation amplitude (μA) for positive step-level feedback
float
default:"20.0"
Stimulation frequency (Hz) for positive step-level feedback
int
default:"30"
Number of pulses for positive step-level feedback
float
default:"2.0"
Stimulation amplitude (μA) for negative step-level feedback
float
default:"60.0"
Stimulation frequency (Hz) for negative step-level feedback
int
default:"90"
Number of pulses for negative step-level feedback

Feedback Stimulation - Episode-level Rewards

int
default:"80"
Number of pulses for positive episode-level feedback
float
default:"40.0"
Stimulation frequency (Hz) for positive episode-level feedback
int
default:"160"
Number of pulses for negative episode-level feedback
float
default:"120.0"
Stimulation frequency (Hz) for negative episode-level feedback
bool
default:"false"
Whether to provide feedback only at episode end (disables step-level feedback)

Reward Feedback Channels

bool
default:"true"
Whether to enable reward-based feedback stimulation
List[int]
default:"[19, 20, 22]"
Channel indices for positive reward feedback
List[int]
default:"[23, 24, 26]"
Channel indices for negative reward feedback

Event-based Feedback

float
default:"10.0"
Distance threshold for triggering movement-based events
Dict[str, EventFeedbackConfig]
Dictionary mapping event names to EventFeedbackConfig objects. Contains configurations for:
  • enemy_kill: Feedback when killing an enemy
  • armor_pickup: Feedback when collecting armor
  • took_damage: Feedback when taking damage
  • ammo_waste: Feedback when wasting ammo
  • approach_target: Feedback when moving closer to target
  • retreat_target: Feedback when moving away from target
See EventFeedbackConfig for detailed field documentation.

Decoder Configuration

bool
default:"false"
Whether to enforce non-negative weights in decoder linear readout heads. Experimental - requires testing
bool
default:"false"
Whether to freeze decoder weights during training. Experimental - requires testing
bool
default:"true"
Whether to zero out decoder biases. Recommended to be true - bias can cause decoder to generate its own predictions
bool
default:"false"
Whether to use MLP decoder instead of linear readout. Prefer false - MLP can learn to play the game instead of relying on neural responses
Optional[int]
default:"32"
Hidden layer size for MLP decoder. Only used if decoder_use_mlp is true. Experimental value - requires testing
float
default:"0.0"
L2 regularization coefficient for decoder weights. Untuned
float
default:"0.0"
L2 regularization coefficient for decoder biases. Untuned
str
default:"none"
Ablation mode for testing decoder behavior. Valid values:
  • none: Normal operation
  • random: Replace spike features with random values
  • zero: Replace spike features with zeros

Wall Detection

int
default:"12"
Number of raycasts for wall detection. Probably less necessary with CNN encoder
int
default:"64"
Maximum range for wall detection raycasts. Keep as is
float
default:"18.0"
Maximum depth distance for wall detection normalization. Already calibrated - keep as is

Encoder Configuration

bool
default:"true"
Whether encoder network weights are trainable. Recommended to be true for reasonable PPO policy gradients, especially with decoder_use_mlp: false
float
default:"-0.10"
Entropy penalty coefficient for the encoder (uses Beta distribution sampling)
bool
default:"true"
Whether to use CNN for visual feature extraction. Testing shows CNN does not overfit/learn on its own - useful to keep true
int
default:"16"
Number of base channels for CNN encoder. Arbitrary value - can be adjusted
int
default:"4"
Downsampling factor for CNN input. Arbitrary value - can be adjusted

Episode Feedback Events

Optional[str]
default:"None"
Specific event name to use for positive episode feedback. If None, uses overall episode reward
Optional[str]
default:"None"
Specific event name to use for negative episode feedback. If None, uses overall episode reward

Surprise-based Feedback Scaling

float
default:"0.25"
Gain for surprise-based feedback scaling. Tune as needed based on neuron responses
float
default:"2.0"
Maximum scaling factor for surprise-based feedback. Tune as needed based on neuron responses
Optional[float]
default:"0.65"
Frequency gain for surprise-based feedback. Tune as needed based on neuron responses
Optional[float]
default:"0.35"
Amplitude gain for surprise-based feedback. Tune as needed based on neuron responses
Optional[float]
default:"2.0"
Maximum frequency scale for surprise-based feedback. Tune as needed based on neuron responses
Optional[float]
default:"1.5"
Maximum amplitude scale for surprise-based feedback. Tune as needed based on neuron responses

Distance Normalization

float
default:"1312.0"
Normalization constant for enemy distance features. Already calibrated - do not change

Usage Example