An action space is the set of possible or permissible actions available to an agent in a given environment. It defines what the agent may choose at each step, while a policy maps states or observations to those choices. section 12.1.2
Action spaces commonly differ by how their choices are represented:
- Discrete spaces contain separate alternatives, such as moving a game agent left or right. section 12.1.2 section 12.3
- Continuous spaces contain values over ranges, such as robot controls or lane-keeping inputs. section 12.1.2
- A stochastic policy assigns probabilities to actions, whereas a deterministic policy selects an action directly. section 12.1.2
CartPole
CartPole has a discrete action space with two choices: Action 0 moves the cart left and Action 1 moves it right. An agent receives +1 for each time step that the pole remains upright, so its policy learns which choice best preserves balance. section 12.3
In an implementation, the environment exposes the action-space size used to configure the policy’s output. For CartPole, `n_actions = env.action_space.n` supplies the number of discrete choices; an actor can then produce one probability per action.
env = gym.make("CartPole-v1") #1
env.seed(0) #2
state_dim = env.observation_space.shape[0] #3
n_actions = env.action_space.n #4
Inspect the CartPole setup that reads the observation dimension and action-space cardinality before constructing the actor and critic. section 12.3

