liveBook · Manning

Action space

As explained in Optimization Algorithms: AI techniques for design, planning, and control problems

An action space is the set of actions available to an agent in an environment.

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

How Optimization Algorithms: AI techniques for design, planning, and control problems covers it

How deep it goes
Distinguishes discrete and continuous actions and shows how a discrete action count configures a policy, without detailing space validation.
Examples
Uses board-game and robot-control contrasts, then works through CartPole’s left and right actions and actor-network output.
What it assumes
Assumes basic reinforcement-learning terms while defining states, observations, policies, trajectories, and returns alongside action spaces.
What you can do after
Apply it via Gym by reading the action-space size and matching the policy output to the environment’s available actions.
How it connects
Connects action spaces to reinforcement learning, environments, states, observations, policies, trajectories, and rewards.

Also explained in

Compare how 2 books explain action space →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Optimization Algorithms: AI techniques for design, planning, and control problems. The section links point to the parts of the book it draws on.