# Zachowanie postaci w grach

EN: **NPC behaviour and game character AI** · id `gamecharacters` · aliases: NPC AI, game character AI, AI postaci niezależnych, AI przeciwników, enemy AI, sztuczna inteligencja NPC

Path: [AI Atlas](https://aiatlasgraph.com/llms.txt) › [AI w grach](https://aiatlasgraph.com/t/gameai.md) › Zachowanie postaci w grach

## Description

- PL: Techniki sterujące postaciami niezależnymi: maszyny stanów, drzewa zachowań, planowanie celów, odnajdywanie drogi oraz postacie prowadzone przez modele językowe.
- EN: Techniques that drive non-player characters: state machines, behaviour trees, goal planning, pathfinding and characters driven by language models.

## In one sentence

- PL: Sposoby, którymi gra decyduje, co robią przeciwnicy, sojusznicy i mieszkańcy świata, żeby wyglądali na myślących.
- EN: The ways a game decides what enemies, allies and townsfolk do, so they seem to think for themselves.

## Problem it solves

- PL: Postacie, które chodzą w kółko, utykają na ścianach albo zawsze reagują tak samo, psują wrażenie żywego świata.
- EN: Characters that walk in circles, get stuck on walls or always react the same way break the sense of a living world.

## What it does

- PL: Jak reżyser statystów na planie: każdy dostaje cel i zestaw ruchów, a razem tworzą wiarygodną scenę.
- EN: Like a director of film extras: each gets a goal and a set of moves, and together they make a believable scene.

## Everyday example

- PL: Strażnik w grze skradankowej słyszy hałas, idzie sprawdzić, a gdy nikogo nie znajduje, wraca na swój obchód.
- EN: A guard in a stealth game hears a noise, goes to check, and when he finds no one, returns to his patrol.

## This concerns you if you…

- PL: projektujesz przeciwników lub postacie do gry
- PL: zastanawiasz się, czemu wrogowie w grach bywają głupi
- PL: chcesz rozmawiać z postaciami w grze własnymi słowami
- EN: design enemies or characters for a game
- EN: wonder why game enemies are sometimes dumb
- EN: want to talk to game characters in your own words

## Keywords

finite state machines · behavior trees · utility AI · GOAP · HTN planning · navigation mesh · steering behaviors · Unreal Engine AI · Unity ML-Agents · generative agents

## How it works

- PL: Postać ma warstwy: wybór celu, plan działań, ruch po świecie i animację. Wybór działań realizują maszyny stanów, drzewa zachowań, systemy użyteczności albo planery, a ruch — odnajdywanie drogi po siatce nawigacyjnej. Modele językowe dochodzą jako warstwa rozmowy i pamięci postaci.
- EN: A character has layers: goal selection, action planning, movement through the world and animation. Action selection uses state machines, behaviour trees, utility systems or planners, and movement uses pathfinding over a navigation mesh. Language models add a layer of conversation and character memory.

## Limits

- PL: Celem jest wiarygodność i frajda, nie optymalność: zbyt sprytny przeciwnik frustruje. Projektanci muszą móc przewidzieć i debugować zachowanie, dlatego w komercyjnych grach dominują metody ręczne, a uczenie maszynowe wchodzi ostrożnie.
- EN: The goal is believability and fun, not optimality: an opponent that is too clever frustrates. Designers must be able to predict and debug behaviour, so hand-authored methods dominate commercial games and machine learning enters cautiously.

## Key terms

- PL: **maszyna stanów**: Postać przełącza się między stanami, np. patrol, pościg, ucieczka.
- PL: **system użyteczności**: Każde działanie dostaje ocenę punktową, wygrywa najwyżej ocenione.
- PL: **blackboard**: Wspólna tablica faktów, z której korzysta logika postaci.
- EN: **state machine**: The character switches between states such as patrol, chase, flee.
- EN: **utility system**: Each action gets a score and the highest-scoring one wins.
- EN: **blackboard**: A shared board of facts that the character logic reads.

## Know first

- [Planowanie automatyczne (PDDL) (Automated planning (PDDL))](https://aiatlasgraph.com/t/classicalplanning.md)
- [Przeszukiwanie heurystyczne (A*) (Heuristic search (A*))](https://aiatlasgraph.com/t/astar.md)

## Subtopics (8 direct, 8 in total)

- [Automaty stanów dla postaci (FSM) (Finite state machines for game characters)](https://aiatlasgraph.com/t/gamefsm.md): A control model where a character is always in exactly one state and events trigger defined transitions; hierarchical and stack variants add sharing and memory.
- [Drzewa zachowań (Behaviour trees)](https://aiatlasgraph.com/t/behaviortrees.md): A hierarchical, modular control structure in which sequence, selector and action nodes are ticked periodically and return success, failure or running.
- [Hierarchiczne planowanie zadań postaci (HTN) (Hierarchical task network planning for game characters)](https://aiatlasgraph.com/t/htngames.md): A planner that decomposes compound tasks into primitive ones via conditioned methods, simulating action effects on a copy of the world state.
- [Mapy wpływów do decyzji taktycznych (Influence maps for tactical decisions)](https://aiatlasgraph.com/t/influencemaps.md): A grid representation of space in which agents spread proximity and threat values that decay with distance; layers combined arithmetically serve tactical queries.
- [Planowanie działań postaci (GOAP) (Goal-oriented action planning for game characters)](https://aiatlasgraph.com/t/goap.md): Real-time planning for characters in which the system searches for a sequence of actions described by preconditions, effects and costs.
- [Postacie rozmawiające dzięki modelom językowym (LLM-driven NPCs and generative agents)](https://aiatlasgraph.com/t/llmnpc.md): Characters and social simulations driven by language models with memory, reflection and planning, grounded in game rules and state.
- [Siatki nawigacyjne i odnajdywanie drogi (Navigation meshes and pathfinding)](https://aiatlasgraph.com/t/navmesh.md): Representing walkable space as a mesh of convex polygons generated from level geometry, with pathfinding and collision avoidance on top.
- [Wybór działań przez punktację (utility AI) (Utility AI for game characters)](https://aiatlasgraph.com/t/utilityai.md): A decision architecture in which every action receives a normalised score from weighted considerations passed through response curves, and the agent picks the highest-utility action.

## Sources

- [Artificial Intelligence and Games (2nd edition)](<https://gameaibook.org/>) `yannakakis-togelius-aigames-2025` · by Georgios N. Yannakakis, Julian Togelius
- [Behavior Trees in Robotics and AI: An Introduction](<https://arxiv.org/abs/1709.00084>) `colledanchise-ogren-bt-2017` · by Michele Colledanchise, Petter Ögren

---

AI Atlas revision 122 (2026-10-30) · HTML: https://aiatlasgraph.com/t/gamecharacters · index: https://aiatlasgraph.com/llms.txt · everything: https://aiatlasgraph.com/llms-full.txt · updated 2026-10-30
