Launch the interactive walkthrough to discover each component, including the 3D Q-Sphere Lab & Python in Colab.
Explore the action space: discrete choices (buttons, moves) versus continuous actuator controls (steering angles, voltages).
gym.spaces.Discrete(n) with cardinality .gym.spaces.Box(low, high, shape) representing an -dimensional real bounding box.| Symbol / Term | Meaning | Beginner Interpretation |
|---|---|---|
| Mean action output | The ideal steering angle or torque | |
| Exploration noise around the mean | ||
| Sampled continuous action | Executed control signal |
Network predicts mean steering angle mu = 15.0 degrees with exploration noise sigma = 1.0 degree.
Result: Smooth continuous actuator command
Network outputs K raw logits; apply Softmax or take argmax for discrete decisions.
Network outputs continuous vector mu; apply Tanh to clamp values within physical actuator limits [-1.0, +1.0].
Problem: Controlling 12 continuous motor torques 500 times per second.
Solution: Continuous action Actor-Critic networks output smooth torque values directly to joint actuators.
Interactive activity component
Demonstrate sampling discrete choices vs continuous Gaussian control signals.
For Google Colab or Jupyter notebooks, run this shell command to install the required dependencies:
!pip install numpy1 import numpy as np
import numpy as np → NumPy random module
1 # 1. Discrete Action Space (e.g. 4 joystick directions): 2 discrete_actions = ["UP", "DOWN", "LEFT", "RIGHT"] 3 chosen_discrete = np.random.choice(discrete_actions) 4 print("Discrete Action Sampled:", chosen_discrete) 5 6 # 2. Continuous Action Space (e.g. Steering Angle [-30 to +30 deg]): 7 mean_steering = 5.2 # Network predicts 5.2 degrees right 8 noise_std = 0.5 # Exploration noise 9 continuous_action = np.random.normal(mean_steering, noise_std) 10 continuous_action = np.clip(continuous_action, -30.0, 30.0) # Enforce physical bounds 11 print(f"Continuous Steering Sampled: {continuous_action:.2f} degrees")
# 1. Discrete Action Space (e.g. 4 joystick directions):
Discrete
discrete_actions = ["UP", "DOWN", "LEFT", "RIGHT"]
Choices
chosen_discrete = np.random.choice(discrete_actions)
Sample discrete
print("Discrete Action Sampled:", chosen_discrete)
Print discrete
# 2. Continuous Action Space (e.g. Steering Angle [-30 to +30 deg]):
Continuous
mean_steering = 5.2 # Network predicts 5.2 degrees right
Predicted mean
noise_std = 0.5 # Exploration noise
Exploration noise
continuous_action = np.random.normal(mean_steering, noise_std)
Sample Gaussian
continuous_action = np.clip(continuous_action, -30.0, 30.0) # Enforce physical bounds
Clip limits
print(f"Continuous Steering Sampled: {continuous_action:.2f} degrees")
Print continuous
Click "Copy for Colab", open Google Colab, paste into a single cell, and run.
1 # ========================================================= 2 # Sampling Discrete vs Continuous Actions in Python 3 # Prepared for Google Colab (Run with Shift + Enter) 4 # ========================================================= 5 6 # Step 1: Install required packages 7 !pip install numpy 8 9 # Step 2: Import libraries 10 import numpy as np 11 12 # Step 3: Run Demonstration 13 # 1. Discrete Action Space (e.g. 4 joystick directions): 14 discrete_actions = ["UP", "DOWN", "LEFT", "RIGHT"] 15 chosen_discrete = np.random.choice(discrete_actions) 16 print("Discrete Action Sampled:", chosen_discrete) 17 18 # 2. Continuous Action Space (e.g. Steering Angle [-30 to +30 deg]): 19 mean_steering = 5.2 # Network predicts 5.2 degrees right 20 noise_std = 0.5 # Exploration noise 21 continuous_action = np.random.normal(mean_steering, noise_std) 22 continuous_action = np.clip(continuous_action, -30.0, 30.0) # Enforce physical bounds 23 print(f"Continuous Steering Sampled: {continuous_action:.2f} degrees")
Selects one discrete string from fixed set.
Samples continuous floating-point angle with Gaussian exploration noise.
Action definitions
Discrete Action Sampled: LEFT Continuous Steering Sampled: 5.48 degrees
Discrete actions are finite integers/labels; continuous actions are real-valued scalars representing physical commands.
Q-learning, Q-table updates, DQN architectures, and exploration-exploitation trade-offs.
Test your understanding with these questions. Remember, this is for learning, not examination!