Skip to content
Matt Regul edited this page Aug 6, 2018 · 5 revisions

Welcome to the df-ai wiki!

File overview

Plugin infrastructure

  • df-ai.cpp - Connects df-ai to DFHack. Implements the ai command and the enable/disable/load/unload df-ai commands.
  • ai.cpp - How the modules communicate with each other. Also implements some helpers such as a few functions that generate descriptions of units, jobs, and items.
  • config.cpp - Handles loading and saving of dfhack-config/df-ai.json.
  • event_manager.cpp - The event system, with three modes: update (which triggers every few frames), state change (which triggers when the current screen changes or when the world ends), and exclusive (which locks out all the other update and state change event listeners until it's done).
  • hooks.cpp - Implementation of lockstep mode. Does some pretty scary things like rewriting the "get current time" function for the entire process.
  • weblegends.cpp - Support for viewing the AI's current state over the internet using weblegends.

Modules

  • population.cpp - Assigns citizens bedrooms, drafts citizens into the military, handles trading, sends the military to attack enemies, and writes down how many die.
  • plan.cpp - Manages the building of rooms and furniture.
    • room.cpp - The data structures that represent rooms and furniture.
    • blueprint.cpp - Handles blueprint-based floor plan generation.
    • plan_priorities.cpp - The priority system that determines which room to build next.
    • plan_legacy.cpp - Hard-coded floor plan layout from older versions.
  • camera.cpp - Decides how often to watch dwarves pick mushrooms instead of watching a giant cave spider eat half the fortress.
  • embark.cpp - Picks a location to start the fortress, which usually isn't in the middle of a volcano. Also handles generating worlds and automatically restarting after fun.
  • stocks.cpp - Tracks the number of various important supplies, like socks, and assigns dwarves to make more socks if there aren't enough. Also decides what we are willing to trade for materials to make more socks.

JSON

Clone this wiki locally