Skip to content

Commit

Permalink
chore: Sync to 6c3a07511537fba884b8ed5dbbd5b52aa877278b on Urist; Rel…
Browse files Browse the repository at this point in the history
…ationshipsDB and a ton of CI fixes/optimizations
  • Loading branch information
jmalek committed Dec 10, 2024
1 parent 154402d commit 8f70e40
Show file tree
Hide file tree
Showing 42 changed files with 341 additions and 157 deletions.
Binary file modified GOAI/GOAI.dmb
Binary file not shown.
5 changes: 4 additions & 1 deletion GOAI/GOAI.dme
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "_a_debug_mode.dm"
#include "_b_debug_modules.dm"
#include "_defines.dm"
#include "_lod_defines.dm"
#include "_need_keys.dm"
#include "_paths.dm"
#include "_trading_defines.dm"
Expand Down Expand Up @@ -62,6 +63,7 @@
#include "_datastructures\registries\faction.dm"
#include "_datastructures\registries\file_cache.dm"
#include "_datastructures\registries\regex_cache.dm"
#include "_datastructures\registries\relationships_db.dm"
#include "_datastructures\registries\smartobjects.dm"
#include "_datastructures\registries\economy\assets.dm"
#include "_datastructures\registries\economy\last_trades.dm"
Expand Down Expand Up @@ -147,6 +149,7 @@
#include "integrations\utility_agent\debug.dm"
#include "integrations\utility_agent\economy_ai.dm"
#include "integrations\utility_agent\global_planactions_repo.dm"
#include "integrations\utility_agent\lod_checks.dm"
#include "integrations\utility_agent\movement.dm"
#include "integrations\utility_agent\orders.dm"
#include "integrations\utility_agent\personality.dm"
Expand Down Expand Up @@ -187,7 +190,7 @@
#include "integrations\utility_agent\senses\pathservice.dm"
#include "integrations\utility_agent\senses\vision.dm"
#include "integrations\utility_agent\systems\movement_system.dm"
#include "maps\combatmap_tabular_mmo.dmm"
#include "maps\combatmap_utility_plan_test.dmm"
#include "utility\actions.dm"
#include "utility\actionset.dm"
#include "utility\actiontemplate.dm"
Expand Down
14 changes: 7 additions & 7 deletions GOAI/_b_debug_modules.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
# define MARKETWATCH_DEBUG_LOGGING 0
# define TRADE_DEBUG_LOGGING 0

#endif
// Undefine to remove warnings for noncritical WIP code stuff
//# define SHOW_GOAI_WIP_WARNINGS 1

// Undefine to remove warnings for noncritical WIP code stuff
# define SHOW_GOAI_WIP_WARNINGS 1
// Undefine to disable drawing debug lines pointing at assorted Stuff
# define ENABLE_GOAI_DEBUG_BEAM_GIZMOS 1

// Undefine to disable drawing debug lines pointing at assorted Stuff
# define ENABLE_GOAI_DEBUG_BEAM_GIZMOS 1
# define ENABLE_GOAI_DEVEL_LOGGING 1
# define ENABLE_GOAI_ERROR_LOGGING 1

# define ENABLE_GOAI_DEVEL_LOGGING 1
# define ENABLE_GOAI_ERROR_LOGGING 1
#endif

#ifndef to_world
#define to_world(message) world << (message)
Expand Down
16 changes: 16 additions & 0 deletions GOAI/_datastructures/faction_data.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@

/datum/faction_data/proc/BuildRelations()
var/datum/relationships/new_relations = new()

if(!GOAI_LIBBED_GLOB_ATTR(relationships_db))
InitRelationshipsDb()

var/list/our_rels = (GOAI_LIBBED_GLOB_ATTR(relationships_db))?[src.name]

if(our_rels)
for(var/reltag in our_rels)
var/relval = our_rels[reltag]

if(isnull(relval))
continue

var/datum/relation_data/reldata = new(relval, RELATIONS_DEFAULT_RELATIONSHIP_WEIGHT)
new_relations.Insert(reltag, reldata)

return new_relations


Expand Down
3 changes: 3 additions & 0 deletions GOAI/_datastructures/pqueue.dm
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,9 @@


/PriorityQueue/BinHeap/Dequeue()
if(!src.L.len)
return

var/popped
BH_HEAPPOP(popped, src.cmp, src.L)
return popped
Expand Down
6 changes: 6 additions & 0 deletions GOAI/_datastructures/registries/economy/assets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,24 @@ GLOBAL_VAR(production_subsystem_last_update_time)
curr_simulation_time += PRODUCTIONSYSTEM_TICKSIZE_DSECONDS

//GOAI_LOG_DEBUG("= PRODUCTION/CONSUMPTION SYSTEM: PROCESSING [faction.name] - simulation tick... =")
#ifdef ENABLE_GOAI_DEVEL_LOGGING
var/recipe_idx = 0
#endif

for(var/list/recipe_asset_deltas in prodconsume_db)
// Go through all Resource 'recipes' and check how much they use/produce stuff...
#ifdef ENABLE_GOAI_DEVEL_LOGGING
recipe_idx++
#endif

if(!recipe_asset_deltas)
// junk entry somehow
GOAI_LOG_ERROR("ERROR: Recipe [recipe_idx] in prodconsume_db has no asset deltas - SKIPPING")
continue

#ifdef ENABLE_GOAI_DEVEL_LOGGING
var/recipe_name = recipe_asset_deltas["recipe_name"]
#endif
//GOAI_LOG_DEBUG("= PRODUCTION/CONSUMPTION SYSTEM: PROCESSING RECIPE [recipe_idx] ([NULL_TO_TEXT(recipe_name)]) for ref [NULL_TO_TEXT(faction_ref)]... =")

// What asset gives rise to this recipe?
Expand Down
27 changes: 19 additions & 8 deletions GOAI/_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,6 @@
# define GOAI_CHEAT_SEE_WAYPOINT_TURF_MAXDIST_CUTOFF (world.view * 3)


/* === Relationships: === */

// Very Big Numbers - should be much bigger than normal relationship val/wgt
// These should effectively force other tags to be ignored entirely.
# define GOAI_REL_LUDICROUS_WEIGHT 10000
# define GOAI_REL_LUDICROUS_VALUE 10000


/* Raycast blocking */
# define RAYCAST_BLOCK_ALL 1
# define RAYCAST_BLOCK_NONE -1
Expand Down Expand Up @@ -280,3 +272,22 @@
// 128+32+16+8+4+2+1 == 191
// Cult mobs, and other things that are basically normal objects but also visible on the supernatural layer
#define GOAI_VISTYPE_SUPERNATURAL 191


/* === Relationships: === */

// Very Big Numbers - should be much bigger than normal relationship val/wgt
// These should effectively force other tags to be ignored entirely.
# define GOAI_REL_LUDICROUS_WEIGHT 10000
# define GOAI_REL_LUDICROUS_VALUE 10000

#define RELATIONS_DEFAULT_RELATIONSHIP_VAL 0
#define RELATIONS_DEFAULT_RELATIONSHIP_WEIGHT 1

#define RELATIONS_DEFAULT_HOSTILITY_THRESHOLD 0
#define RELATIONS_DEFAULT_ALLIANCE_THRESHOLD 100

#define RELATIONS_DEFAULT_SELF_FACTION_RELATION_VAL 100
#define RELATIONS_DEFAULT_SELF_FACTION_RELATION_WEIGHT 1
#define RELATIONS_DEFAULT_SELF_HIDDENFACTION_RELATION_VAL 50
#define RELATIONS_DEFAULT_SELF_HIDDENFACTION_RELATION_WEIGHT 1
64 changes: 64 additions & 0 deletions GOAI/_lod_defines.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/* -- LOD Levels -- */

/*
// In this case, we're talking about AI LODs specifically.
//
// This is an instance of the general optimization technique of Don't Run Wot You Don't Need.
// AI is a fairly expensive part of any game, so we want to skip running it as much as possible.
// If the AI of a Thing currently cannot possibly affect what the players will see, we don't want to bother.
//
// GOAI AI APIs provide filters that run against the LOD levels below and trim down the AI logic accordingly.
// For example, individual mob AIs should only run at UNIT_LOW LOD or higher.
// The available Actions are also filtered by min and max LOD they are available on.
*/

// The LOD values are descending to make things more intuitive (higher number => higher detail).
// I hope I don't live to regret this decision when the time comes to add more levels lol.

// Disable the AI altogether. Like the Pause attribute, but toggled dynamically by a check.
#define GOAI_LOD_DONTRUN 0

// Elevated detail. Mostly headroom if we need higher-than-usual LOD somewhere. Could be used for boss type things.
#define GOAI_LOD_DETAILED 9

// Standard level of processing; all standard actions available, all things fully simulated.
// "Unit" - b/c for mob AIs, we'd simulate each unit fully.
#define GOAI_LOD_UNIT 8

// Still process units individually, but at reduced fidelity.
// Meant for things like mobs in an area/Z-level without players.
#define GOAI_LOD_UNIT_LOW 7

// Collapses the first level of abstraction ('Unit') entirely.
// For mobs, that would be moving *Squad* representations only - hence the name.
// The name is mostly a mnemonic, don't get too hung up about it.
#define GOAI_LOD_SQUAD 6

// Reduced-fidelity processing but still at 'Squad' level.
// Similar to UNIT_LOW - we're near enough that we still See The Thing, but 'zoomed out' enough it loses detail.
#define GOAI_LOD_SQUAD_LOW 5

// Collapses the second level of abstraction ('Squad') entirely.
// Where Squad level ignores individual Units by replacing them with whole-Squad logic,
// here we remove Squad-level autonomy and manipulate them all in one place.
// The name is an extension of the military metaphor.
// Most likely though, this will be Faction AI processing for active Faction operations.
#define GOAI_LOD_PLATOON 4

// You know the drill by now. Groups of Squads, with some further simplifications on top.
#define GOAI_LOD_PLATOON_LOW 3

// Ignore everything but the grand-strategic layer.
#define GOAI_LOD_FACTION 2

// This is so reduced it's almost looping back to DONTRUN.
// Only run top-level, Faction stuff, and don't bother with anything like resources or operations;
// just the coarsest facts like updating relationships to everyone else.
#define GOAI_LOD_FACTION_LOW 1

// Convenience aliases to simplify maintenance.
// Anything that just cares about max/min/default can use these
// so that even if we add more levels, we don't need to replace 'em everywhere.
#define GOAI_LOD_LOWEST GOAI_LOD_FACTION_LOW
#define GOAI_LOD_STANDARD GOAI_LOD_UNIT
#define GOAI_LOD_HIGHEST GOAI_LOD_DETAILED
2 changes: 1 addition & 1 deletion GOAI/_paths.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#define GOAI_DATA_PATH(FP) "code/modules/urist/GOAI/goai_data/" + ##FP
#define GOAI_SMARTOBJECT_PATH(FP) "code/modules/urist/GOAI/goai_data/smartobject_definitions/" + ##FP
#define GOAI_FACTIONSPEC_PATH(FP) "code/modules/urist/GOAI/goai_data/faction_definitions/" + ##FP
#define GOAI_PERSONALITY_PATH(FP) "goai_data/personality_templates/" + ##FP
#define GOAI_PERSONALITY_PATH(FP) "code/modules/urist/GOAI/goai_data/personality_templates/" + ##FP

#endif

Expand Down
2 changes: 2 additions & 0 deletions GOAI/_utility_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
# define JSON_KEY_ACT_ACTIVE "active"
# define JSON_KEY_ACT_PRECONDS "preconditions"
# define JSON_KEY_ACT_EFFECTS "effects"
# define JSON_KEY_ACT_MINLOD "min_lod"
# define JSON_KEY_ACT_MAXLOD "max_lod"

// ActionSet schema:
# define JSON_KEY_ACTSET_NAME "name"
Expand Down
2 changes: 1 addition & 1 deletion GOAI/basics/brain/brain_actions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
var/list/actionslist


/datum/brain/proc/GetAvailableActions()
/datum/brain/proc/GetAvailableActions(var/no_cache = null)
/* Abstraction layer over Action updates.
// We need this to let nearby Smart Objects etc. yield
// Actions to the planner.
Expand Down
1 change: 1 addition & 0 deletions GOAI/basics/brain/brain_memory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

var/relevant_age = by_age ? retrieved_mem.GetAge() : retrieved_mem.GetFreshness()

to_world_log("[src.name] memories for [mem_key] - Relevant age [relevant_age], ttl [retrieved_mem.ttl]")
if(relevant_age < retrieved_mem.ttl)
// We already checked for parent preference - no need to redo that.
return retrieved_mem
Expand Down
4 changes: 2 additions & 2 deletions GOAI/basics/brain/brain_relations.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
var/datum/relationships/relations

// For relations: if less than this, we are hostile to the target, if more - neutral (or allied)
var/hostility_threshold = -5
var/hostility_threshold = RELATIONS_DEFAULT_HOSTILITY_THRESHOLD

// For relations: if higher than this, we treat the target as an ally
var/ally_threshold = 50
var/ally_threshold = RELATIONS_DEFAULT_ALLIANCE_THRESHOLD
1 change: 0 additions & 1 deletion GOAI/basics/relationships.dm
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,4 @@
var/weighted_val = factor * rel_val
total_val += weighted_val


return total_val
4 changes: 4 additions & 0 deletions GOAI/basics/senses.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
var/processing = FALSE // to avoid calling stuff multiple times per tick
var/enabled = TRUE

// AI LOD stuff
var/min_lod = GOAI_LOD_LOWEST
var/max_lod = GOAI_LOD_STANDARD


/sense/proc/ProcessTick(var/owner)
// overall logic goes here;
Expand Down
4 changes: 4 additions & 0 deletions GOAI/basics/testing/ui_hackery.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#ifdef GOAI_LIBRARY_FEATURES

// Extending the default controls for easier development

# define MODE_PASSTHRU 0
Expand Down Expand Up @@ -264,3 +266,5 @@

GOAI_LOG_DEBUG_WORLD("Client [mobclient] [select_enabled ? "now" : "no longer"] does CommanderGiveMoveOrderClick...")
return

#endif
5 changes: 5 additions & 0 deletions GOAI/goai_data/relationships_db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"neutral": {
"neutral": 0
}
}
5 changes: 2 additions & 3 deletions GOAI/goai_data/smartobject_definitions/autodoor.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
"goal_state": {
"open": 1
}
}
,
},
"priority": 4,
"considerations": [
{
"name": "Closed Door Nearby",
"lo_mark": 0.1,
"lo_mark": 0,
"hi_mark": 1,
"input_proc": "/proc/consideration_input_is_passable",
"input_args": {
Expand Down
6 changes: 3 additions & 3 deletions GOAI/goai_data/smartobject_definitions/humanoid_agent.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"name": "Flee",
"description": "Bravely turn tail and run because you're scared.",
"handler": "/datum/utility_ai/mob_commander/proc/FleeFrom",
"priority": 16,
"priority": 10,
"context_procs": ["/proc/ctxfetcher_get_memory_value"],
"context_args": [
{
Expand Down Expand Up @@ -263,8 +263,8 @@
},
{
"name": "IsFoe",
"lo_mark": -50,
"hi_mark": 0,
"lo_mark": -1,
"hi_mark": 1,
"noise_scale": 0,
"input_proc": "/proc/consideration_input_relationship_score",
"input_args": {
Expand Down
10 changes: 5 additions & 5 deletions GOAI/goai_data/smartobject_definitions/simplemob_agent.json
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@
},
{
"name": "IsFoe",
"lo_mark": -50,
"hi_mark": 0,
"lo_mark": -1,
"hi_mark": 1,
"noise_scale": 0,
"input_proc": "/proc/consideration_input_relationship_score",
"input_args": {
Expand Down Expand Up @@ -356,8 +356,8 @@
},
{
"name": "IsFoe",
"lo_mark": -50,
"hi_mark": 0,
"lo_mark": -1,
"hi_mark": 1,
"noise_scale": 0,
"input_proc": "/proc/consideration_input_relationship_score",
"input_args": {
Expand Down Expand Up @@ -396,7 +396,7 @@
"input_key": "threat",
"from_context": 1
},
"curve_proc": "/proc/curve_antilinear"
"curve_proc": "/proc/curve_linear"
},
{
"name": "ThreatInLOS",
Expand Down
2 changes: 1 addition & 1 deletion GOAI/goai_data/smartobject_definitions/ss13_autodoor.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"considerations": [
{
"name": "Closed Door Nearby",
"lo_mark": 0.1,
"lo_mark": 0,
"hi_mark": 1,
"input_proc": "/proc/consideration_input_is_passable",
"input_args": {
Expand Down
4 changes: 2 additions & 2 deletions GOAI/integrations/smartobject_definitions/faction_data.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

GOAI_HAS_UTILITY_ACTIONS_BOILERPLATE_VARLIST(/datum/faction_data, actionset_files)

/datum/faction_data/GetUtilityActions(var/requester, var/list/args = null)
/datum/faction_data/GetUtilityActions(var/requester, var/list/args = null, var/no_cache = FALSE)
var/list/my_action_sets = list()

if(!src.actionset_files)
Expand All @@ -13,7 +13,7 @@ GOAI_HAS_UTILITY_ACTIONS_BOILERPLATE_VARLIST(/datum/faction_data, actionset_file
continue

try
var/datum/action_set/myset = ActionSetFromJsonFile(action_bundle_json_fp)
var/datum/action_set/myset = ActionSetFromJsonFile(action_bundle_json_fp, no_cache)
myset.origin = src
my_action_sets.Add(myset)

Expand Down
Loading

0 comments on commit 8f70e40

Please sign in to comment.