Professional Documents
Culture Documents
Individual
sections referenced from the TOC are marked with anchors in square brackets to
make grepping for them easier.
Code in the Z layer may not depend on files outside the Z layer.
## Events [events]
TBD
# Files [files]
Angband uses three types of files for storing data: edit files, which contain
the game's static data, pref files, which contain UI settings,
and save files, which contain the state of a game in progress.
## Startup [startup]
Execution begins in main.c, which runs frontend-independent initialization code,
then continues in the appropriate main-*.c file for the current frontend. After
the game engine is initialized, the player is loaded (or generated) and gameplay
begins.
## Gameplay [gameplay]
Once the simulation is set up, the game main loop in dungeon.c's play_game()
[play-game] is responsible for stepping the simulation.
### dungeon.c: The game main loop [game-main-loop]
The main loop of the game is inside play_game(), commented as "/* Process */",
in typical understated Angband style. This loop runs once per time that either
the level is regenerated, the player dies, or the player quits the game. Each
iteration through, the this loop runs the level main loop to completion for an
individual level.
* All monsters with more energy than the player act ([process-monsters])
* The player acts ([process-player])
* All other monsters act ([process-monsters])
* The UI updates ([update-stuff])
* The world acts ([process-world])
* End-of-turn housekeeping is done
* notice_stuff, which deals with pack combining and dropping ignored items;
* update_stuff(), which recalculates derived bonuses, AI data, vision, seen
monsters, and other things based on the flags in player->upkeep->update;
* redraw_stuff(), which signals the UI to redraw changed sections of the
game state;
* handle_stuff(), which calls update_stuff() and redraw_stuff() if needed.
These functions are called during every game loop, after the player and all
monsters have acted.
# Monster AI [monster-ai]