A state space describes the possible situations an agent may encounter in an environment. In Gym, the environment exposes its observation/state space so an implementation can determine how state is represented and how large the problem is. FrozenLake uses a discrete state space: its size is the number of available discrete state values. Other environments use continuous or ranged values. section 11.1.1 section 11.2
State representation directly shapes the learning mechanism. For tabular Q-learning, the state-space size and action-space size define a Q-table: each row corresponds to a state, and each column records an action’s learned quality in that state. This is practical for a small discrete environment, but continuous spaces make a table unsuitable; deep reinforcement learning instead uses a neural network in place of the state or Q-table. section 11.1.1 section 11.2
Inspect a state space before choosing an agent design:
- Create the Gym environment and query observation_space and action_space to identify the available representation and action count. section 11.1.1 section 11.2
- Use a zero-filled array sized as (state_size, action_size) when states and actions are discrete and a tabular Q-learner is appropriate. section 11.1.1
- Treat more possible states as greater environment complexity; the illustrated comparison raises state-space size to the action-space size. section 11.2
- Pass observation size into a DQN when replacing a table with a network; its input accepts the state space and its output covers the action space. section 11.5
From FrozenLake table to LunarLander network
FrozenLake initializes one Q-table row per discrete state and selects values from that row for available actions. For LunarLander, the agent reads the observation-space shape, reshapes each state for training, and feeds it to a three-layer network whose final layer has one output per action. The contrast shows why state representation matters: table lookup fits the small discrete case, while a neural model handles the richer observation input. section 11.1.1 section 11.5
Compare Gym environments by their action and state spaces and by the resulting relative-complexity estimate before selecting a tabular or deep-learning approach. section 11.2
