### DF-AI Outdoor Room Configuration Source: https://github.com/benlubar/df-ai/wiki/Blueprints Specifies the configuration for outdoor spaces within the DF-AI project, defining a starting room tag and a list of associated outdoor room tags. ```Go-like start: RoomTag outdoor: []RoomTag ``` -------------------------------- ### DFHACK Plugin Configuration and Installation Source: https://github.com/benlubar/df-ai/blob/develop/CMakeLists.txt This snippet defines how to build the df-ai project as a DFHack plugin using the `DFHACK_PLUGIN` macro. It specifies the plugin name, source files, libraries, and compiler flags for both GCC and MSVC. Additionally, it sets up installation rules for blueprint JSON files. ```cmake DFHACK_PLUGIN(df-ai ${PROJECT_SRCS} LINK_LIBRARIES ${PROJECT_LIBS} COMPILE_FLAGS_GCC "-Wall -Wextra -Werror -Wno-unused-parameter" COMPILE_FLAGS_MSVC "/W3 /WX") INSTALL(DIRECTORY rooms/ DESTINATION df-ai-blueprints/rooms FILES_MATCHING PATTERN "*.json") INSTALL(DIRECTORY plans/ DESTINATION df-ai-blueprints/plans FILES_MATCHING PATTERN "*.json") ``` -------------------------------- ### DF-AI Placeholders Configuration Source: https://github.com/benlubar/df-ai/wiki/Blueprints Defines the placeholder configurations for the DF-AI project, mapping tags to room names and variable names to string values. ```Go-like tags: map[Tag][]RoomName variables: map[VariableName]string ``` -------------------------------- ### DF-AI Priorities Configuration Source: https://github.com/benlubar/df-ai/wiki/Blueprints Specifies the priority settings for the DF-AI project, using a list of 'Priority' objects. ```Go-like priorities: []Priority ``` -------------------------------- ### DFHack Plugin Infrastructure Source: https://github.com/benlubar/df-ai/wiki/Home Details the core C++ files responsible for integrating df-ai with DFHack, including command handling and module communication. ```cpp 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`](https://github.com/BenLubar/df-ai/wiki/AI-Settings). 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|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](https://github.com/BenLubar/weblegends). ``` -------------------------------- ### DF-AI Limits Configuration Source: https://github.com/benlubar/df-ai/wiki/Blueprints Details the limits configuration for rooms and their instances in the DF-AI project, using maps to associate room names with integer arrays for limits. ```Go-like limits: map[RoomName][2]int instance_limits: map[RoomName]map[RoomInstanceName][2]int ``` -------------------------------- ### DF-AI Plan Configuration Source: https://github.com/benlubar/df-ai/wiki/Blueprints Defines the configuration parameters for the DF-AI project's plan settings, including retry mechanisms, failure limits, and padding values for spatial arrangements. ```Go-like max_retries: int max_failures: int padding_x: [2]int padding_y: [2]int ``` -------------------------------- ### DFHack CMake Configuration for DF-AI Source: https://github.com/benlubar/df-ai/wiki/Compiling This snippet shows how to add the df-ai plugin to the DFHack build system by including its subdirectory in the custom CMakeLists.txt file. This is a crucial step for compiling DFHack with DF-AI support. ```cmake add_subdirectory(df-ai) ``` -------------------------------- ### Default df-ai Configuration Source: https://github.com/benlubar/df-ai/wiki/AI-Settings This JSON object represents the default configuration settings for the df-ai project. It includes options for camera control, announcement display, embark preferences, performance settings like lockstep and FPS meter, AI management for labors and nobles, game state handling (no_quit), blueprint planning verbosity, random embark choices, movie recording, world size, and console/log output. ```js { "camera" : true, "cancel_announce" : 0, "embark_options" : { "Aquifer" : 0, "BottomlessPit" : -1, "Chasm" : -1, "Clay" : -1, "DeepMetal" : -1, "DimensionX" : 3, "DimensionY" : 2, "Drainage" : -1, "Elevation" : -1, "Evil" : -1, "FluxStone" : -1, "MagmaPipe" : -1, "MagmaPool" : -1, "OtherFeatures" : -1, "Rain" : -1, "River" : -1, "Savagery" : 2, "ShallowMetal" : -1, "Soil" : -1, "Temperature" : -1, "UndergroundPool" : -1, "UndergroundRiver" : -1 }, "fps_meter" : true, "lockstep" : false, "manage_labors" : "autolabor", "manage_nobles" : true, "no_quit" : true, "plan_allow_legacy" : true, "plan_verbosity" : 2, "random_embark" : true, "random_embark_world" : "", "record_movie" : false, "world_size" : 1, "write_console" : true, "write_log" : true } ``` -------------------------------- ### df-ai Configuration Settings Source: https://github.com/benlubar/df-ai/wiki/AI-Settings This section details the various configuration parameters for the df-ai project. Each parameter controls a specific aspect of the AI's behavior or game interaction, such as camera following, job cancellation announcements, FPS meter display, lockstep mode, labor management, noble assignment, game quitting behavior, floor plan generation, log verbosity, embark options, movie recording, world generation size, and console/log output. ```APIDOC Settings: camera: boolean - Should the AI automatically follow dwarves it thinks are interesting? Default: true cancel_announce: integer - How many job cancellation notices to show (0: none, 1: some, 2: most, 3: all) Default: 0 embark_options: object - Configuration for AI embark location selection. See "Embark Options" section for details. fps_meter: boolean - Should the AI hide the FPS meter when in a menu? Default: true lockstep: boolean - Should the AI make Dwarf Fortress think it's running at 100 simulation ticks, 50 graphical frames per second? Notes: Does not work in TEXT mode. The game will not accept input while this is set to true. Default: false manage_labors: string - Name of a DFHack plugin that manages labors, or "" for no automated labor management. Supported: "autolabor", "labormanger". Default: "autolabor" manage_nobles: boolean - Should the AI assign administrators in the fortress? Default: true no_quit: boolean - Should the AI keep the game running after it loses? Default: true plan_allow_legacy: boolean - Should the AI use the legacy floor plan generator if it fails to generate a floor plan using blueprints? Default: true plan_verbosity: integer - How much information about the blueprint should the AI write to the log (-1: none, 0: summary, 1: room placement summary, 2: placements that succeeded, 3: placements that failed, 4: exits being discarded). Default: 2 random_embark: boolean - Should the AI automatically pick an embark location? Default: true random_embark_world: string - The name of the region to embark on, or "" to generate a new world. Default: "" record_movie: boolean - Should the AI automatically record CMV files while it plays? Default: false world_size: integer - Size of World to generate (0: pocket, 1: smaller, 2: small, 3: medium, 4: large). Default: 1 write_console: boolean - Should the AI say what it's thinking in the DFHack console? Default: true write_log: boolean - Should the AI say what it's thinking in df-ai.log? Default: true ``` -------------------------------- ### DF-AI Room Instance Structure Source: https://github.com/benlubar/df-ai/wiki/Blueprints Defines the structure for a 'Room Instance' within the DF-AI project, which can optionally contain placeholders. It explicitly forbids the placeholder field in certain contexts. ```Go-like p: optional<[]Placeholder> forbids placeholder field ``` -------------------------------- ### DF-AI Room Template Structure Source: https://github.com/benlubar/df-ai/wiki/Blueprints Defines the structure for a 'Room Template' in the DF-AI project, which explicitly allows the placeholder field. ```Go-like allows placeholder field ``` -------------------------------- ### df-ai JSON Configuration Source: https://github.com/benlubar/df-ai/wiki/Home Outlines the structure of JSON files used for blueprints, room instances, and room templates within the df-ai project. ```json plans/*.json - [[plans|Blueprints#Plan]] rooms/instances/*/*.json - [[room instances|Blueprints#Instance]] rooms/templates/*/*.json - [[room templates|Blueprints#Template]] ``` -------------------------------- ### Git Versioning and Header Generation Source: https://github.com/benlubar/df-ai/blob/develop/CMakeLists.txt This snippet demonstrates how to capture Git information (description, commit hash, and tagged status) during the CMake build process and write it into a header file (`df-ai-git-describe.h`). This is useful for embedding version information directly into the compiled code. ```cmake cmake_minimum_required(VERSION 3.11.0) PROJECT (df-ai) execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=8 --long WORKING_DIRECTORY "${df-ai_SOURCE_DIR}" OUTPUT_VARIABLE DF_AI_GIT_DESCRIPTION) execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD WORKING_DIRECTORY "${df-ai_SOURCE_DIR}" OUTPUT_VARIABLE DF_AI_GIT_COMMIT) execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --abbrev=8 --exact-match WORKING_DIRECTORY "${df-ai_SOURCE_DIR}" RESULT_VARIABLE DF_AI_GIT_TAGGED_RESULT OUTPUT_QUIET ERROR_QUIET) set(git_describe_tmp_h ${df-ai_SOURCE_DIR}/df-ai-git-describe.tmp.h) set(git_describe_h ${df-ai_SOURCE_DIR}/df-ai-git-describe.h) file(WRITE ${git_describe_tmp_h} "") macro(git_describe_definition var) string(STRIP "${${var}}" GIT_DEF_VALUE) file(APPEND ${git_describe_tmp_h} "#define ${var} \"${GIT_DEF_VALUE}\"\n") endmacro() git_describe_definition(DF_AI_GIT_DESCRIPTION) git_describe_definition(DF_AI_GIT_COMMIT) if(${DF_AI_GIT_TAGGED_RESULT} EQUAL 0) file(APPEND ${git_describe_tmp_h} "#define DF_AI_GIT_TAGGED\n") endif() execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${git_describe_tmp_h} ${git_describe_h}) ``` -------------------------------- ### DF-AI Room Structure Source: https://github.com/benlubar/df-ai/wiki/Blueprints Defines the basic structure of a 'Room' in the DF-AI project, including optional furniture and nested rooms. ```Go-like f: optional<[]Furniture> r: optional<[]Room> ``` -------------------------------- ### Embark Options Configuration Source: https://github.com/benlubar/df-ai/wiki/AI-Settings This section details the embark options for the df-ai project, allowing users to control where the AI chooses to embark. It lists various location search parameters and their corresponding values, where -1 typically means 'N/A' and 0 represents the first option. ```json "embark_options" : { "Aquifer" : 0, "BottomlessPit" : -1, "Chasm" : -1, "Clay" : -1, "DeepMetal" : -1, "DimensionX" : 3, "DimensionY" : 2, "Drainage" : -1, "Elevation" : -1, "Evil" : -1, "FluxStone" : -1, "MagmaPipe" : -1, "MagmaPool" : -1, "OtherFeatures" : -1, "Rain" : -1, "River" : -1, "Savagery" : 2, "ShallowMetal" : -1, "Soil" : -1, "Temperature" : -1, "UndergroundPool" : -1, "UndergroundRiver" : -1 } ``` -------------------------------- ### DF-AI Console Commands Source: https://github.com/benlubar/df-ai/blob/develop/README.md Displays a list of available console commands for interacting with the DF-AI plugin. These commands allow users to manage and query the AI's state and actions. ```dfhack help ai ``` -------------------------------- ### Project Source and Header File Definitions Source: https://github.com/benlubar/df-ai/blob/develop/CMakeLists.txt This snippet defines the lists of source (`.cpp`) and header (`.h`) files that constitute the df-ai project. It also sets header files to be read-only during the build process and appends them to the source list for compilation. ```cmake SET(PROJECT_SRCS df-ai.cpp ai.cpp config.cpp hooks.cpp population.cpp population_death.cpp population_justice.cpp population_military.cpp population_nobles.cpp population_occupations.cpp population_pets.cpp plan.cpp plan_assign.cpp plan_cistern.cpp plan_construct.cpp plan_find.cpp plan_persist.cpp plan_priorities.cpp plan_setup.cpp plan_setup_blueprint.cpp plan_setup_screen.cpp plan_smooth.cpp plan_task.cpp blueprint.cpp blueprint_furniture.cpp blueprint_room.cpp blueprint_merge.cpp blueprint_template.cpp stocks.cpp stocks_detect.cpp stocks_equipment.cpp stocks_farm.cpp stocks_find.cpp stocks_forge.cpp stocks_manager.cpp stocks_queue.cpp stocks_trade.cpp stocks_update.cpp camera.cpp embark.cpp room.cpp room_describe.cpp trade_helpers.cpp trade_manager.cpp event_manager.cpp exclusive_callback.cpp weblegends.cpp military.cpp pause.cpp log.cpp variable_string.cpp ) SET(PROJECT_HDRS ai.h config.h debug.h hooks.h population.h plan.h plan_priorities.h plan_setup.h blueprint.h stocks.h camera.h embark.h room.h trade.h event_manager.h exclusive_callback.h dfhack_shared.h df-ai-git-describe.h apply.h variable_string.h ) IF("${DFHACK_BUILD_ARCH}" STREQUAL "32") set(CMAKE_CXX_COMPILER_ARCHITECTURE_ID X86) set(CMAKE_SIZEOF_VOID_P 4) ELSE() set(CMAKE_CXX_COMPILER_ARCHITECTURE_ID x64) set(CMAKE_SIZEOF_VOID_P 8) ENDIF() SET_SOURCE_FILES_PROPERTIES( ${PROJECT_HDRS} PROPERTIES HEADER_FILE_ONLY TRUE) LIST(APPEND PROJECT_SRCS ${PROJECT_HDRS}) ``` -------------------------------- ### df-ai Modules Source: https://github.com/benlubar/df-ai/wiki/Home Describes the C++ modules that manage various aspects of the Dwarf Fortress AI, such as population, planning, camera control, embark, and stock management. ```cpp 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|Blueprints]]. 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](https://dwarffortresswiki.org/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. trade.cpp - Code converted from [mifki's Remote Dwarf Fortress iOS app](https://github.com/mifki/dfremote) used to decide how many prepared meals should be traded for the twigs and berries brought by elves each year. ``` -------------------------------- ### DF-AI Console Commands Source: https://github.com/benlubar/df-ai/wiki/Console-Commands This section lists and describes the console commands for interacting with DF-AI. These commands allow users to enable/disable features, check AI status, manage game events, control game speed and camera, abandon fortresses, and validate configurations. ```APIDOC enable df-ai - Enables DF-AI. Best used from the title screen or at the start of a fresh embark. - Note: DF-AI does not handle already established forts but can resume from previous df-ai saves. - Additional embark & fort settings can be found in `dfhack-config/df-ai.json`. ``` ```APIDOC ai - Shows the current status of the AI. ``` ```APIDOC ai version - Displays information that uniquely identifies the current build of DF-AI. ``` ```APIDOC ai report - Writes a detailed status report to `df-ai-report.log`. ``` ```APIDOC ai enable events - Writes game events in JSON format to `df-ai-events.json`. ``` ```APIDOC ai disable events - Stops writing game events to `df-ai-events.json`. ``` ```APIDOC ai enable lockstep - Runs Dwarf Fortress as fast as possible, locking animations to the frame rate instead of real time. - **Warning**: May cause crashes; use at your own risk. ``` ```APIDOC ai disable lockstep - Reverts the game speed from `ai enable lockstep`, returning Dwarf Fortress to its configured frame rate. ``` ```APIDOC ai enable camera - Allows the AI to control the camera, automatically focusing on different tasks and events. - Note: The player can still move the camera at any time, but the AI will retake control. - Zoom-level is unaffected. ``` ```APIDOC ai disable camera - Reverts camera control from the AI, returning it solely to the player. ``` ```APIDOC ai abandon - Abandons the current fortress and returns to the title screen. ``` ```APIDOC ai validate - Verifies that `df-ai-blueprints` is set up correctly. ``` -------------------------------- ### Boost Dependency and Library Linking Source: https://github.com/benlubar/df-ai/blob/develop/CMakeLists.txt This snippet configures CMake to find and link against the Boost libraries, specifically requiring version 1.67.0 and the 'context' component. It also sets various Boost usage flags for static linking, release builds, and non-debug runtimes. ```cmake set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_DEBUG_LIBS OFF) set(Boost_USE_RELEASE_LIBS ON) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) set(Boost_USE_DEBUG_RUNTIME OFF) find_package(Boost 1.67.0 REQUIRED COMPONENTS context) include_directories(${Boost_INCLUDE_DIRS}) LIST(APPEND PROJECT_LIBS jsoncpp_static lua ${ZLIB_LIBRARIES} ${Boost_LIBRARIES}) IF(UNIX) IF(APPLE) LIST(APPEND PROJECT_LIBS ${CMAKE_BINARY_DIR}/SDL) ELSE() LIST(APPEND PROJECT_LIBS SDL) ENDIF() ENDIF() SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDFAI_RELEASE") ``` -------------------------------- ### DF-AI Furniture Structure Source: https://github.com/benlubar/df-ai/wiki/Room Defines the structure of a 'Furniture' object, representing items placed within rooms. It includes type, construction details, position, and interaction flags. ```APIDOC Furniture: type: enum construction: enum dig: enum x: int y: int z: int target: FurnitureID has_users: int ignore: bool makeroom: bool internal: bool comment: VariableString ``` -------------------------------- ### DF-AI Data Structures Source: https://github.com/benlubar/df-ai/wiki/Priorities Defines the core data structures and types used within the DF-AI project. This includes enums, optional types, filters, and counts for various entities like Rooms and Furniture. ```APIDOC Project Structure: - action: enum - continue: optional - match: Filter - count: Count Between: - int Or: - 0(min): int|null - 1(max): int|null Filter: - *name*: optional - *name*_not: optional Count: - *name*: optional Count: - match: T|[]T - is: Between Enum: - *name*: optional - *name*_not: optional EnumSet: - *name*: optional - *name*_not: optional String: - *name*: optional - *name*_not: optional Room: - status: Enum - type: Enum - corridor_type: Enum - farm_type: Enum - stockpile_type: Enum - nobleroom_type: Enum - outpost_type: Enum - location_type: Enum - cistern_type: Enum - workshop_type: Enum - furnace_type: Enum - raw_type: String - comment: String - accesspath: Count - layout: Count - has_owner: optional - has_squad: optional - level: Between - workshop: Filter - users: Between - stock_disable: EnumSet - stock_specific1: optional - stock_specific2: optional - has_users: Between - furnished: optional - queue_dig: optional - temporary: optional - outdoor: optional - channeled: optional Furniture: - type: Enum - construction: Enum - dig: Enum - target: Filter - users: Between - has_users: Between - ignore: optional - makeroom: optional - internal: optional - comment: String ``` -------------------------------- ### Enable DF-AI Plugin Source: https://github.com/benlubar/df-ai/blob/develop/README.md Enables the DF-AI plugin within the DFHack console. This command is the primary way to activate the AI's control over Dwarf Fortress. ```dfhack enable df-ai ``` -------------------------------- ### DF-AI Exit Structure Source: https://github.com/benlubar/df-ai/wiki/Room Defines the structure of an 'Exit' object, used to represent connections between rooms. It includes positional data and optional contextual information. ```APIDOC Exit: 0(tag): RoomTag 1(x): int 2(y): int 3(z): int 4(context): optional ``` -------------------------------- ### DF-AI Room Structure Source: https://github.com/benlubar/df-ai/wiki/Room Defines the structure of a 'Room' object within the DF-AI project, including its various properties and their types. This serves as a schema for room data. ```APIDOC Room: type: enum corridor_type: enum farm_type: enum stockpile_type: enum nobleroom_type: enum outpost_type: enum location_type: enum cistern_type: enum workshop_type: enum furnace_type: enum raw_type: VariableString comment: VariableString min: [3]int max: [3]int exits: []Exit accesspath: []RoomID layout: []FurnitureID level: int noblesuite: NobleSuiteID queue: int workshop: RoomID stock_disable: []enum stock_specific1: bool stock_specific2: bool has_users: int temporary: bool outdoor: bool single_biome: bool require_walls: bool require_floor: bool require_grass: int in_corridor: bool ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.