---
key: resource/state-pattern
type: resource
id: state-pattern
lang: en
title: 'State: Game Programming Patterns'
summary: 'The author’s chapter on finite state machines, states, and transitions.'
updatedAt: null
status: active
url: 'https://gamemechanics.pro/en/resources/#resource-state-pattern'
jsonUrl: 'https://gamemechanics.pro/api/v1/knowledge/en/resource/state-pattern.json'
markdownUrl: 'https://gamemechanics.pro/content/knowledge/en/resource/state-pattern.md'
aliases: []
tags:
  - book
  - ''
  - foundations
sourceIds:
  - source-3817d420df0baa92
sources:
  - id: source-3817d420df0baa92
    title: 'State: Game Programming Patterns'
    url: >-
      https://github.com/munificent/game-programming-patterns/blob/master/book/state.markdown
    verifiedAt: null
relations:
  - type: uses
    direction: incoming
    label: Used in these materials
    key: lesson/state-machines
    title: States and transitions
    url: 'https://gamemechanics.pro/en/lessons/state-machines/'
    jsonUrl: 'https://gamemechanics.pro/api/v1/knowledge/en/lesson/state-machines.json'
    markdownUrl: 'https://gamemechanics.pro/content/knowledge/en/lesson/state-machines.md'
  - type: uses
    direction: incoming
    label: Used in these materials
    key: catalog/activity-simulators
    title: Activity and profession simulators
    url: 'https://gamemechanics.pro/en/mechanics/activity-simulators/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/catalog/activity-simulators.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/catalog/activity-simulators.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/activity-simulators--t127
    title: 'Farming, gardening and animal husbandry'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t127/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/activity-simulators--t127.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/activity-simulators--t127.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/activity-simulators--t128
    title: 'Cooking, recipes and kitchen work'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t128/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/activity-simulators--t128.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/activity-simulators--t128.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/activity-simulators--t129
    title: 'Fishing, hunting and harvesting trades'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t129/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/activity-simulators--t129.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/activity-simulators--t129.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/activity-simulators--t131
    title: 'Cleaning, sorting and restoration'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t131/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/activity-simulators--t131.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/activity-simulators--t131.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/activity-simulators--t132
    title: 'Construction, earthmoving and machinery'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t132/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/activity-simulators--t132.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/activity-simulators--t132.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/activity-simulators--t133
    title: 'Medicine, rescue and emergency services'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t133/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/activity-simulators--t133.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/activity-simulators--t133.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/activity-simulators--t134
    title: Technical incident investigation
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t134/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/activity-simulators--t134.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/activity-simulators--t134.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/activity-simulators--t135
    title: 'Document checks, inspections and control'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t135/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/activity-simulators--t135.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/activity-simulators--t135.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/activity-simulators--t136
    title: 'Delivery, dispatching and customer service'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t136/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/activity-simulators--t136.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/activity-simulators--t136.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/activity-simulators--t137
    title: Scientific experiments and instruments
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t137/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/activity-simulators--t137.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/activity-simulators--t137.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/activity-simulators--t138
    title: 'Business, office and bureaucracy simulators'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t138/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/activity-simulators--t138.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/activity-simulators--t138.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: catalog/melee-combat
    title: Melee and combat systems
    url: 'https://gamemechanics.pro/en/mechanics/melee-combat/'
    jsonUrl: 'https://gamemechanics.pro/api/v1/knowledge/en/catalog/melee-combat.json'
    markdownUrl: 'https://gamemechanics.pro/content/knowledge/en/catalog/melee-combat.md'
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/melee-combat--t011
    title: Hand-to-hand combat and beat ’em ups
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/melee-combat--t011/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/melee-combat--t011.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/melee-combat--t011.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/melee-combat--t012
    title: Fighting games and duels
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/melee-combat--t012/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/melee-combat--t012.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/melee-combat--t012.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/melee-combat--t013
    title: Combos and character action
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/melee-combat--t013/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/melee-combat--t013.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/melee-combat--t013.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/melee-combat--t014
    title: Soulslikes and stamina management
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/melee-combat--t014/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/melee-combat--t014.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/melee-combat--t014.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/melee-combat--t015
    title: Hack and slash
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/melee-combat--t015/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/melee-combat--t015.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/melee-combat--t015.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/melee-combat--t016
    title: 'Blocking, parrying and counterattacks'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/melee-combat--t016/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/melee-combat--t016.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/melee-combat--t016.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/melee-combat--t017
    title: 'Grapples, throws and wrestling'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/melee-combat--t017/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/melee-combat--t017.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/melee-combat--t017.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/melee-combat--t018
    title: Crowd combat and space control
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/melee-combat--t018/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/melee-combat--t018.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/melee-combat--t018.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/melee-combat--t020
    title: 'Breakable parts, injuries and conditions'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/melee-combat--t020/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/melee-combat--t020.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/melee-combat--t020.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: catalog/progression-rewards
    title: 'Progression, rewards and retention'
    url: 'https://gamemechanics.pro/en/mechanics/progression-rewards/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/catalog/progression-rewards.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/catalog/progression-rewards.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/progression-rewards--t240
    title: Unlocking abilities and expanding available actions
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/progression-rewards--t240/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/progression-rewards--t240.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/progression-rewards--t240.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/progression-rewards--t241
    title: 'Collections, albums and set completion'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/progression-rewards--t241/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/progression-rewards--t241.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/progression-rewards--t241.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/progression-rewards--t242
    title: 'Achievements, challenges and mastery'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/progression-rewards--t242/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/progression-rewards--t242.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/progression-rewards--t242.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/progression-rewards--t243
    title: 'Loot, rarity and reward distribution'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/progression-rewards--t243/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/progression-rewards--t243.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/progression-rewards--t243.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/progression-rewards--t244
    title: 'Idle, incremental and offline progress'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/progression-rewards--t244/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/progression-rewards--t244.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/progression-rewards--t244.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/progression-rewards--t245
    title: 'Prestige, resets and renewed progression'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/progression-rewards--t245/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/progression-rewards--t245.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/progression-rewards--t245.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: catalog/role-playing-systems
    title: Role-playing systems
    url: 'https://gamemechanics.pro/en/mechanics/role-playing-systems/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/catalog/role-playing-systems.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/catalog/role-playing-systems.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/role-playing-systems--t049
    title: Character creation and attribute allocation
    url: >-
      https://gamemechanics.pro/en/knowledge/mechanic/role-playing-systems--t049/
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/role-playing-systems--t049.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/role-playing-systems--t049.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/role-playing-systems--t050
    title: 'Classes, specializations and role switching'
    url: >-
      https://gamemechanics.pro/en/knowledge/mechanic/role-playing-systems--t050/
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/role-playing-systems--t050.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/role-playing-systems--t050.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/role-playing-systems--t051
    title: Builds and ability synergies
    url: >-
      https://gamemechanics.pro/en/knowledge/mechanic/role-playing-systems--t051/
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/role-playing-systems--t051.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/role-playing-systems--t051.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/role-playing-systems--t052
    title: Party roles and team composition
    url: >-
      https://gamemechanics.pro/en/knowledge/mechanic/role-playing-systems--t052/
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/role-playing-systems--t052.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/role-playing-systems--t052.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/role-playing-systems--t053
    title: 'Equipment, affixes and item sets'
    url: >-
      https://gamemechanics.pro/en/knowledge/mechanic/role-playing-systems--t053/
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/role-playing-systems--t053.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/role-playing-systems--t053.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/role-playing-systems--t054
    title: 'Status effects, elements and resistances'
    url: >-
      https://gamemechanics.pro/en/knowledge/mechanic/role-playing-systems--t054/
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/role-playing-systems--t054.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/role-playing-systems--t054.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/role-playing-systems--t055
    title: Learning skills through use
    url: >-
      https://gamemechanics.pro/en/knowledge/mechanic/role-playing-systems--t055/
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/role-playing-systems--t055.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/role-playing-systems--t055.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/role-playing-systems--t057
    title: 'Reputation, factions and alignment'
    url: >-
      https://gamemechanics.pro/en/knowledge/mechanic/role-playing-systems--t057/
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/role-playing-systems--t057.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/role-playing-systems--t057.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/role-playing-systems--t058
    title: 'Quests, contracts and consequences'
    url: >-
      https://gamemechanics.pro/en/knowledge/mechanic/role-playing-systems--t058/
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/role-playing-systems--t058.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/role-playing-systems--t058.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: catalog/run-structures
    title: Roguelikes and run structure
    url: 'https://gamemechanics.pro/en/mechanics/run-structures/'
    jsonUrl: 'https://gamemechanics.pro/api/v1/knowledge/en/catalog/run-structures.json'
    markdownUrl: 'https://gamemechanics.pro/content/knowledge/en/catalog/run-structures.md'
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/run-structures--t060
    title: Traditional turn-based roguelikes
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/run-structures--t060/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/run-structures--t060.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/run-structures--t060.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/run-structures--t061
    title: Action roguelikes
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/run-structures--t061/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/run-structures--t061.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/run-structures--t061.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/run-structures--t062
    title: Survivor-likes and automatic attacks
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/run-structures--t062/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/run-structures--t062.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/run-structures--t062.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/run-structures--t063
    title: Dungeon crawlers and resource attrition
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/run-structures--t063/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/run-structures--t063.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/run-structures--t063.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: catalog/social-cooperation
    title: Social relationships and shared play
    url: 'https://gamemechanics.pro/en/mechanics/social-cooperation/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/catalog/social-cooperation.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/catalog/social-cooperation.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/social-cooperation--t200
    title: Caring for pets and dependent characters
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/social-cooperation--t200/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/social-cooperation--t200.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/social-cooperation--t200.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/social-cooperation--t204
    title: Asymmetric roles and abilities
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/social-cooperation--t204/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/social-cooperation--t204.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/social-cooperation--t204.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/social-cooperation--t206
    title: 'Rescue, support and shared responsibility'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/social-cooperation--t206/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/social-cooperation--t206.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/social-cooperation--t206.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/social-cooperation--t207
    title: 'Betrayal, coalitions and temporary alliances'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/social-cooperation--t207/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/social-cooperation--t207.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/social-cooperation--t207.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/social-cooperation--t198
    title: Social simulations and everyday life
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/social-cooperation--t198/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/social-cooperation--t198.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/social-cooperation--t198.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/social-cooperation--t202
    title: Social deduction and hidden roles
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/social-cooperation--t202/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/social-cooperation--t202.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/social-cooperation--t202.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/social-cooperation--t208
    title: 'Party games, trivia and collective guessing'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/social-cooperation--t208/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/social-cooperation--t208.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/social-cooperation--t208.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: catalog/stealth-infiltration
    title: 'Stealth, infiltration and escape'
    url: 'https://gamemechanics.pro/en/mechanics/stealth-infiltration/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/catalog/stealth-infiltration.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/catalog/stealth-infiltration.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/stealth-infiltration--t031
    title: 'Visibility, noise and detection'
    url: >-
      https://gamemechanics.pro/en/knowledge/mechanic/stealth-infiltration--t031/
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/stealth-infiltration--t031.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/stealth-infiltration--t031.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/stealth-infiltration--t032
    title: 'Suspicion, alerts and searching'
    url: >-
      https://gamemechanics.pro/en/knowledge/mechanic/stealth-infiltration--t032/
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/stealth-infiltration--t032.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/stealth-infiltration--t032.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/stealth-infiltration--t033
    title: Hiding bodies and traces
    url: >-
      https://gamemechanics.pro/en/knowledge/mechanic/stealth-infiltration--t033/
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/stealth-infiltration--t033.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/stealth-infiltration--t033.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/stealth-infiltration--t034
    title: Disguises and social infiltration
    url: >-
      https://gamemechanics.pro/en/knowledge/mechanic/stealth-infiltration--t034/
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/stealth-infiltration--t034.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/stealth-infiltration--t034.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/stealth-infiltration--t035
    title: 'Lures, distractions and sabotage'
    url: >-
      https://gamemechanics.pro/en/knowledge/mechanic/stealth-infiltration--t035/
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/stealth-infiltration--t035.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/stealth-infiltration--t035.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/stealth-infiltration--t036
    title: 'Tailing, reconnaissance and counter-surveillance'
    url: >-
      https://gamemechanics.pro/en/knowledge/mechanic/stealth-infiltration--t036/
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/stealth-infiltration--t036.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/stealth-infiltration--t036.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/stealth-infiltration--t037
    title: Heists and coordinated infiltration
    url: >-
      https://gamemechanics.pro/en/knowledge/mechanic/stealth-infiltration--t037/
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/stealth-infiltration--t037.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/stealth-infiltration--t037.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/stealth-infiltration--t038
    title: 'Escape, chases and evading pursuit'
    url: >-
      https://gamemechanics.pro/en/knowledge/mechanic/stealth-infiltration--t038/
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/stealth-infiltration--t038.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/stealth-infiltration--t038.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: catalog/systemic-worlds
    title: 'Systemic worlds, randomness and NPC behavior'
    url: 'https://gamemechanics.pro/en/mechanics/systemic-worlds/'
    jsonUrl: 'https://gamemechanics.pro/api/v1/knowledge/en/catalog/systemic-worlds.json'
    markdownUrl: 'https://gamemechanics.pro/content/knowledge/en/catalog/systemic-worlds.md'
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/systemic-worlds--t260
    title: Systemic interactions and immersive sims
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/systemic-worlds--t260/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/systemic-worlds--t260.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/systemic-worlds--t260.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/systemic-worlds--t262
    title: 'Physical materials, deformation and destruction'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/systemic-worlds--t262/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/systemic-worlds--t262.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/systemic-worlds--t262.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/systemic-worlds--t263
    title: 'Ecology, food chains and environmental recovery'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/systemic-worlds--t263/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/systemic-worlds--t263.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/systemic-worlds--t263.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/systemic-worlds--t265
    title: 'Character routines, needs and memory'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/systemic-worlds--t265/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/systemic-worlds--t265.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/systemic-worlds--t265.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/systemic-worlds--t266
    title: Creature training and taming
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/systemic-worlds--t266/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/systemic-worlds--t266.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/systemic-worlds--t266.md
  - type: uses
    direction: incoming
    label: Used in these materials
    key: mechanic/systemic-worlds--t269
    title: 'Simulated societies, populations and autonomous communities'
    url: 'https://gamemechanics.pro/en/knowledge/mechanic/systemic-worlds--t269/'
    jsonUrl: >-
      https://gamemechanics.pro/api/v1/knowledge/en/mechanic/systemic-worlds--t269.json
    markdownUrl: >-
      https://gamemechanics.pro/content/knowledge/en/mechanic/systemic-worlds--t269.md
placements: []
supersededBy: []
attributes:
  kind: book
  format: null
  language: en
  authors: null
endsAt: null
provenance: >-
  Original editorial recommendation. The external material retains its author’s
  rights.
license: CC-BY-4.0
codeLicense: MIT
attribution: gamemechanics.pro contributors
---
# State: Game Programming Patterns

id: state-pattern
type: resource
key: resource/state-pattern
lang: en
status: active
url: https://gamemechanics.pro/en/resources/#resource-state-pattern

The author’s chapter on finite state machines, states, and transitions.

## When to use it

The author’s chapter on finite state machines, states, and transitions.

## Connected materials

- Used in these materials: [States and transitions](https://gamemechanics.pro/en/lessons/state-machines/) (key: lesson/state-machines)
- Used in these materials: [Activity and profession simulators](https://gamemechanics.pro/en/mechanics/activity-simulators/) (key: catalog/activity-simulators)
- Used in these materials: [Farming, gardening and animal husbandry](https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t127/) (key: mechanic/activity-simulators--t127)
- Used in these materials: [Cooking, recipes and kitchen work](https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t128/) (key: mechanic/activity-simulators--t128)
- Used in these materials: [Fishing, hunting and harvesting trades](https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t129/) (key: mechanic/activity-simulators--t129)
- Used in these materials: [Cleaning, sorting and restoration](https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t131/) (key: mechanic/activity-simulators--t131)
- Used in these materials: [Construction, earthmoving and machinery](https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t132/) (key: mechanic/activity-simulators--t132)
- Used in these materials: [Medicine, rescue and emergency services](https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t133/) (key: mechanic/activity-simulators--t133)
- Used in these materials: [Technical incident investigation](https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t134/) (key: mechanic/activity-simulators--t134)
- Used in these materials: [Document checks, inspections and control](https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t135/) (key: mechanic/activity-simulators--t135)
- Used in these materials: [Delivery, dispatching and customer service](https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t136/) (key: mechanic/activity-simulators--t136)
- Used in these materials: [Scientific experiments and instruments](https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t137/) (key: mechanic/activity-simulators--t137)
- Used in these materials: [Business, office and bureaucracy simulators](https://gamemechanics.pro/en/knowledge/mechanic/activity-simulators--t138/) (key: mechanic/activity-simulators--t138)
- Used in these materials: [Melee and combat systems](https://gamemechanics.pro/en/mechanics/melee-combat/) (key: catalog/melee-combat)
- Used in these materials: [Hand-to-hand combat and beat ’em ups](https://gamemechanics.pro/en/knowledge/mechanic/melee-combat--t011/) (key: mechanic/melee-combat--t011)
- Used in these materials: [Fighting games and duels](https://gamemechanics.pro/en/knowledge/mechanic/melee-combat--t012/) (key: mechanic/melee-combat--t012)
- Used in these materials: [Combos and character action](https://gamemechanics.pro/en/knowledge/mechanic/melee-combat--t013/) (key: mechanic/melee-combat--t013)
- Used in these materials: [Soulslikes and stamina management](https://gamemechanics.pro/en/knowledge/mechanic/melee-combat--t014/) (key: mechanic/melee-combat--t014)
- Used in these materials: [Hack and slash](https://gamemechanics.pro/en/knowledge/mechanic/melee-combat--t015/) (key: mechanic/melee-combat--t015)
- Used in these materials: [Blocking, parrying and counterattacks](https://gamemechanics.pro/en/knowledge/mechanic/melee-combat--t016/) (key: mechanic/melee-combat--t016)
- Used in these materials: [Grapples, throws and wrestling](https://gamemechanics.pro/en/knowledge/mechanic/melee-combat--t017/) (key: mechanic/melee-combat--t017)
- Used in these materials: [Crowd combat and space control](https://gamemechanics.pro/en/knowledge/mechanic/melee-combat--t018/) (key: mechanic/melee-combat--t018)
- Used in these materials: [Breakable parts, injuries and conditions](https://gamemechanics.pro/en/knowledge/mechanic/melee-combat--t020/) (key: mechanic/melee-combat--t020)
- Used in these materials: [Progression, rewards and retention](https://gamemechanics.pro/en/mechanics/progression-rewards/) (key: catalog/progression-rewards)
- Used in these materials: [Unlocking abilities and expanding available actions](https://gamemechanics.pro/en/knowledge/mechanic/progression-rewards--t240/) (key: mechanic/progression-rewards--t240)
- Used in these materials: [Collections, albums and set completion](https://gamemechanics.pro/en/knowledge/mechanic/progression-rewards--t241/) (key: mechanic/progression-rewards--t241)
- Used in these materials: [Achievements, challenges and mastery](https://gamemechanics.pro/en/knowledge/mechanic/progression-rewards--t242/) (key: mechanic/progression-rewards--t242)
- Used in these materials: [Loot, rarity and reward distribution](https://gamemechanics.pro/en/knowledge/mechanic/progression-rewards--t243/) (key: mechanic/progression-rewards--t243)
- Used in these materials: [Idle, incremental and offline progress](https://gamemechanics.pro/en/knowledge/mechanic/progression-rewards--t244/) (key: mechanic/progression-rewards--t244)
- Used in these materials: [Prestige, resets and renewed progression](https://gamemechanics.pro/en/knowledge/mechanic/progression-rewards--t245/) (key: mechanic/progression-rewards--t245)
- Used in these materials: [Role-playing systems](https://gamemechanics.pro/en/mechanics/role-playing-systems/) (key: catalog/role-playing-systems)
- Used in these materials: [Character creation and attribute allocation](https://gamemechanics.pro/en/knowledge/mechanic/role-playing-systems--t049/) (key: mechanic/role-playing-systems--t049)
- Used in these materials: [Classes, specializations and role switching](https://gamemechanics.pro/en/knowledge/mechanic/role-playing-systems--t050/) (key: mechanic/role-playing-systems--t050)
- Used in these materials: [Builds and ability synergies](https://gamemechanics.pro/en/knowledge/mechanic/role-playing-systems--t051/) (key: mechanic/role-playing-systems--t051)
- Used in these materials: [Party roles and team composition](https://gamemechanics.pro/en/knowledge/mechanic/role-playing-systems--t052/) (key: mechanic/role-playing-systems--t052)
- Used in these materials: [Equipment, affixes and item sets](https://gamemechanics.pro/en/knowledge/mechanic/role-playing-systems--t053/) (key: mechanic/role-playing-systems--t053)
- Used in these materials: [Status effects, elements and resistances](https://gamemechanics.pro/en/knowledge/mechanic/role-playing-systems--t054/) (key: mechanic/role-playing-systems--t054)
- Used in these materials: [Learning skills through use](https://gamemechanics.pro/en/knowledge/mechanic/role-playing-systems--t055/) (key: mechanic/role-playing-systems--t055)
- Used in these materials: [Reputation, factions and alignment](https://gamemechanics.pro/en/knowledge/mechanic/role-playing-systems--t057/) (key: mechanic/role-playing-systems--t057)
- Used in these materials: [Quests, contracts and consequences](https://gamemechanics.pro/en/knowledge/mechanic/role-playing-systems--t058/) (key: mechanic/role-playing-systems--t058)
- Used in these materials: [Roguelikes and run structure](https://gamemechanics.pro/en/mechanics/run-structures/) (key: catalog/run-structures)
- Used in these materials: [Traditional turn-based roguelikes](https://gamemechanics.pro/en/knowledge/mechanic/run-structures--t060/) (key: mechanic/run-structures--t060)
- Used in these materials: [Action roguelikes](https://gamemechanics.pro/en/knowledge/mechanic/run-structures--t061/) (key: mechanic/run-structures--t061)
- Used in these materials: [Survivor-likes and automatic attacks](https://gamemechanics.pro/en/knowledge/mechanic/run-structures--t062/) (key: mechanic/run-structures--t062)
- Used in these materials: [Dungeon crawlers and resource attrition](https://gamemechanics.pro/en/knowledge/mechanic/run-structures--t063/) (key: mechanic/run-structures--t063)
- Used in these materials: [Social relationships and shared play](https://gamemechanics.pro/en/mechanics/social-cooperation/) (key: catalog/social-cooperation)
- Used in these materials: [Caring for pets and dependent characters](https://gamemechanics.pro/en/knowledge/mechanic/social-cooperation--t200/) (key: mechanic/social-cooperation--t200)
- Used in these materials: [Asymmetric roles and abilities](https://gamemechanics.pro/en/knowledge/mechanic/social-cooperation--t204/) (key: mechanic/social-cooperation--t204)
- Used in these materials: [Rescue, support and shared responsibility](https://gamemechanics.pro/en/knowledge/mechanic/social-cooperation--t206/) (key: mechanic/social-cooperation--t206)
- Used in these materials: [Betrayal, coalitions and temporary alliances](https://gamemechanics.pro/en/knowledge/mechanic/social-cooperation--t207/) (key: mechanic/social-cooperation--t207)
- Used in these materials: [Social simulations and everyday life](https://gamemechanics.pro/en/knowledge/mechanic/social-cooperation--t198/) (key: mechanic/social-cooperation--t198)
- Used in these materials: [Social deduction and hidden roles](https://gamemechanics.pro/en/knowledge/mechanic/social-cooperation--t202/) (key: mechanic/social-cooperation--t202)
- Used in these materials: [Party games, trivia and collective guessing](https://gamemechanics.pro/en/knowledge/mechanic/social-cooperation--t208/) (key: mechanic/social-cooperation--t208)
- Used in these materials: [Stealth, infiltration and escape](https://gamemechanics.pro/en/mechanics/stealth-infiltration/) (key: catalog/stealth-infiltration)
- Used in these materials: [Visibility, noise and detection](https://gamemechanics.pro/en/knowledge/mechanic/stealth-infiltration--t031/) (key: mechanic/stealth-infiltration--t031)
- Used in these materials: [Suspicion, alerts and searching](https://gamemechanics.pro/en/knowledge/mechanic/stealth-infiltration--t032/) (key: mechanic/stealth-infiltration--t032)
- Used in these materials: [Hiding bodies and traces](https://gamemechanics.pro/en/knowledge/mechanic/stealth-infiltration--t033/) (key: mechanic/stealth-infiltration--t033)
- Used in these materials: [Disguises and social infiltration](https://gamemechanics.pro/en/knowledge/mechanic/stealth-infiltration--t034/) (key: mechanic/stealth-infiltration--t034)
- Used in these materials: [Lures, distractions and sabotage](https://gamemechanics.pro/en/knowledge/mechanic/stealth-infiltration--t035/) (key: mechanic/stealth-infiltration--t035)
- Used in these materials: [Tailing, reconnaissance and counter-surveillance](https://gamemechanics.pro/en/knowledge/mechanic/stealth-infiltration--t036/) (key: mechanic/stealth-infiltration--t036)
- Used in these materials: [Heists and coordinated infiltration](https://gamemechanics.pro/en/knowledge/mechanic/stealth-infiltration--t037/) (key: mechanic/stealth-infiltration--t037)
- Used in these materials: [Escape, chases and evading pursuit](https://gamemechanics.pro/en/knowledge/mechanic/stealth-infiltration--t038/) (key: mechanic/stealth-infiltration--t038)
- Used in these materials: [Systemic worlds, randomness and NPC behavior](https://gamemechanics.pro/en/mechanics/systemic-worlds/) (key: catalog/systemic-worlds)
- Used in these materials: [Systemic interactions and immersive sims](https://gamemechanics.pro/en/knowledge/mechanic/systemic-worlds--t260/) (key: mechanic/systemic-worlds--t260)
- Used in these materials: [Physical materials, deformation and destruction](https://gamemechanics.pro/en/knowledge/mechanic/systemic-worlds--t262/) (key: mechanic/systemic-worlds--t262)
- Used in these materials: [Ecology, food chains and environmental recovery](https://gamemechanics.pro/en/knowledge/mechanic/systemic-worlds--t263/) (key: mechanic/systemic-worlds--t263)
- Used in these materials: [Character routines, needs and memory](https://gamemechanics.pro/en/knowledge/mechanic/systemic-worlds--t265/) (key: mechanic/systemic-worlds--t265)
- Used in these materials: [Creature training and taming](https://gamemechanics.pro/en/knowledge/mechanic/systemic-worlds--t266/) (key: mechanic/systemic-worlds--t266)
- Used in these materials: [Simulated societies, populations and autonomous communities](https://gamemechanics.pro/en/knowledge/mechanic/systemic-worlds--t269/) (key: mechanic/systemic-worlds--t269)

## Sources and provenance

Original editorial recommendation. The external material retains its author’s rights.

- [State: Game Programming Patterns](https://github.com/munificent/game-programming-patterns/blob/master/book/state.markdown) (id: source-3817d420df0baa92)

CC-BY-4.0 · gamemechanics.pro contributors
