Skip to content
This repository was archived by the owner on May 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions code/__DEFINES/ai.dm
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

///All AI machinery heat production is multiplied by this value
#define AI_TEMPERATURE_MULTIPLIER 8 //Thermodynamics? No... No I don't think that's a thing. Balance so we don't use an insane amount of power to produce noticeable heat
#define AI_TEMPERATURE_MULTIPLIER 5 //Thermodynamics? No... No I don't think that's a thing. Balance so we don't use an insane amount of power to produce noticeable heat
///Temperature limit of all AI machinery
#define AI_TEMP_LIMIT 283.15 //10C, much hotter than a normal server room for leniency :)
#define AI_TEMP_LIMIT 288.15 //15C, much hotter than a normal server room for leniency :)


///How many ticks can an AI data core store? When this amount of ticks have passed while it's in an INVALID state it can no longer be used by an AI
Expand All @@ -18,13 +18,15 @@
#define AI_PROJECT_CAMERAS "Visiblity Upgrades"
#define AI_PROJECT_INDUCTION "Induction"
#define AI_PROJECT_SURVEILLANCE "Surveillance"
#define AI_PROJECT_EFFICIENCY "Efficiency"
#define AI_PROJECT_MISC "Misc."
//Update this list if you add any new ones, else the category won't show up in the UIs
GLOBAL_LIST_INIT(ai_project_categories, list(
AI_PROJECT_HUDS,
AI_PROJECT_CAMERAS,
AI_PROJECT_SURVEILLANCE,
AI_PROJECT_INDUCTION,
AI_PROJECT_EFFICIENCY,
AI_PROJECT_MISC
))

Expand All @@ -35,14 +37,17 @@ GLOBAL_LIST_INIT(ai_project_categories, list(


//AI hardware
#define AI_CPU_BASE_POWER_USAGE 1500
#define AI_CPU_BASE_POWER_USAGE 1250

#define AI_RAM_POWER_USAGE 750
#define AI_RAM_POWER_USAGE 500

//Needs UI change to properly work!
#define AI_MAX_CPUS_PER_RACK 4
//Needs UI change to properly work!
#define AI_MAX_RAM_PER_RACK 4

///How many AI research points does 1 THz generate?
#define AI_RESEARCH_PER_CPU 10
#define AI_RESEARCH_PER_CPU 7.5

//How long between each data core being able to send a warning. Wouldn't want any spam if we had jittery temps would we?
#define AI_DATA_CORE_WARNING_COOLDOWN (5 MINUTES)
1 change: 1 addition & 0 deletions code/game/objects/effects/spawners/lootdrop.dm
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@
name = "secure AI circuit board spawner"
loot = list(
/obj/item/circuitboard/computer/aiupload,
/obj/item/circuitboard/computer/ai_upload_download,
/obj/item/circuitboard/computer/borgupload
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -999,9 +999,10 @@
icon_state = "science"
build_path = /obj/machinery/ai/server_cabinet
req_components = list(
/obj/item/stock_parts/matter_bin = 4,
/obj/item/stock_parts/manipulator = 2,
/obj/item/stack/sheet/glass = 2)
/obj/item/stock_parts/matter_bin = 2,
/obj/item/stock_parts/capacitor = 2,
/obj/item/stack/sheet/glass = 2,
/obj/item/stack/cable_coil = 1)

/obj/item/circuitboard/machine/ai_core_display
name = "AI Core Display (Machine Board)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

#define AI_MACHINE_TOO_HOT "Environment too hot"
#define AI_MACHINE_NO_MOLES "Environment lacks an atmosphere"

/obj/machinery/ai
name = "You shouldn't see this!"
desc = "You shouldn't see this!"
Expand All @@ -18,6 +21,22 @@
if(istype(T, /turf/open/space) || total_moles < 10)
return FALSE

if(env.return_temperature() > AI_TEMP_LIMIT || !env.heat_capacity())
if(env.return_temperature() > GLOB.ai_os.get_temp_limit() || !env.heat_capacity())
return FALSE
return TRUE

/obj/machinery/ai/proc/get_holder_status()
if(stat & (BROKEN|NOPOWER|EMPED))
return FALSE

var/turf/T = get_turf(src)
var/datum/gas_mixture/env = T.return_air()
if(!env)
return AI_MACHINE_NO_MOLES
var/total_moles = env.total_moles()
if(istype(T, /turf/open/space) || total_moles < 10)
return AI_MACHINE_NO_MOLES

if(env.return_temperature() > GLOB.ai_os.get_temp_limit() || !env.heat_capacity())
return AI_MACHINE_TOO_HOT

38 changes: 32 additions & 6 deletions code/modules/mob/living/silicon/ai/decentralized/ai_data_core.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ GLOBAL_VAR_INIT(primary_data_core, null)
/obj/machinery/ai/data_core
name = "AI Data Core"
desc = "A complicated computer system capable of emulating the neural functions of an organic being at near-instantanous speeds."
icon = 'icons/obj/machines/telecomms.dmi'
icon_state = "hub"
icon = 'icons/obj/machines/ai_core.dmi'
icon_state = "core-offline"

circuit = /obj/item/circuitboard/machine/ai_data_core

Expand All @@ -18,15 +18,35 @@ GLOBAL_VAR_INIT(primary_data_core, null)
var/valid_ticks = MAX_AI_DATA_CORE_TICKS //Limited to MAX_AI_DATA_CORE_TICKS. Decrement by 1 every time we have an invalid tick, opposite when valid

var/warning_sent = FALSE
COOLDOWN_DECLARE(warning_cooldown)

var/TimerID //party time
//Heat production multiplied by this
var/heat_modifier = 1
//Power modifier, power modified by this. Be aware this indirectly changes heat since power => heat
var/power_modifier = 1


/obj/machinery/ai/data_core/Initialize()
. = ..()
GLOB.data_cores += src
if(primary && !GLOB.primary_data_core)
GLOB.primary_data_core = src
update_icon()
RefreshParts()

/obj/machinery/ai/data_core/RefreshParts()
var/new_heat_mod = 1
var/new_power_mod = 1
for(var/obj/item/stock_parts/capacitor/C in component_parts)
new_power_mod -= (C.rating - 1) / 50 //Max -24% at tier 4 parts, min -0% at tier 1

for(var/obj/item/stock_parts/matter_bin/M in component_parts)
new_heat_mod -= (M.rating - 1) / 15 //Max -40% at tier 4 parts, min -0% at tier 1

heat_modifier = new_heat_mod
power_modifier = new_power_mod
active_power_usage = AI_DATA_CORE_POWER_USAGE * power_modifier

/obj/machinery/ai/data_core/process()
calculate_validity()
Expand Down Expand Up @@ -66,6 +86,9 @@ GLOBAL_VAR_INIT(primary_data_core, null)
//NOTE: See /obj/machinery/status_display/examine in ai_core_display.dm
/obj/machinery/ai/data_core/examine(mob/user)
. = ..()
var/holder_status = get_holder_status()
if(holder_status)
. += span_warning("Machinery non-functional. Reason: [holder_status]")
if(!isobserver(user))
return
. += "<b>Networked AI Laws:</b>"
Expand All @@ -92,6 +115,7 @@ GLOBAL_VAR_INIT(primary_data_core, null)
return TRUE
return FALSE


/obj/machinery/ai/data_core/proc/calculate_validity()
valid_ticks = clamp(valid_ticks, 0, MAX_AI_DATA_CORE_TICKS)

Expand All @@ -109,8 +133,9 @@ GLOBAL_VAR_INIT(primary_data_core, null)
for(var/mob/living/silicon/ai/AI in contents)
if(!AI.is_dying)
AI.relocate()
if(!warning_sent)
if(!warning_sent && COOLDOWN_FINISHED(src, warning_cooldown))
warning_sent = TRUE
COOLDOWN_START(src, warning_cooldown, AI_DATA_CORE_WARNING_COOLDOWN)
var/list/send_to = GLOB.ai_list.Copy()
for(var/mob/living/silicon/ai/AI in send_to)
if(AI.is_dying)
Expand All @@ -126,7 +151,7 @@ GLOBAL_VAR_INIT(primary_data_core, null)
var/turf/T = get_turf(src)
var/datum/gas_mixture/env = T.return_air()
if(env.heat_capacity())
var/temperature_increase = active_power_usage / env.heat_capacity() //1 CPU = 1000W. Heat capacity = somewhere around 3000-4000. Aka we generate 0.25 - 0.33 K per second, per CPU.
var/temperature_increase = (active_power_usage / env.heat_capacity()) * heat_modifier //1 CPU = 1000W. Heat capacity = somewhere around 3000-4000. Aka we generate 0.25 - 0.33 K per second, per CPU.
env.set_temperature(env.return_temperature() + temperature_increase * AI_TEMPERATURE_MULTIPLIER) //assume all input power is dissipated
T.air_update_turf()

Expand All @@ -148,8 +173,9 @@ GLOBAL_VAR_INIT(primary_data_core, null)
if(!(stat & (BROKEN|NOPOWER|EMPED)))
if(!valid_data_core())
return
var/mutable_appearance/on_overlay = mutable_appearance(icon, "[initial(icon_state)]_on")
add_overlay(on_overlay)
icon_state = "core"
else
icon_state = "core-offline"

/obj/machinery/ai/data_core/proc/partytime()
var/current_color = random_color()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ GLOBAL_DATUM_INIT(ai_os, /datum/ai_os, new)
var/list/cpu_assigned
var/list/ram_assigned

var/temp_limit = AI_TEMP_LIMIT

/datum/ai_os/New()
update_hardware()
cpu_assigned = list()
Expand Down Expand Up @@ -124,3 +126,6 @@ GLOBAL_DATUM_INIT(ai_os, /datum/ai_os, new)
cpu_assigned[AI] = 0

update_allocations()

/datum/ai_os/proc/get_temp_limit()
return temp_limit
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ GLOBAL_VAR_INIT(ai_control_code, random_nukecode(6))
name = "\improper AI control console"
desc = "Used for accessing the central AI repository from which AIs can be downloaded or uploaded."
req_access = list(ACCESS_RD)
circuit = /obj/item/circuitboard/computer/aifixer
icon_keyboard = "tech_key"
icon_screen = "ai-fixer"
light_color = LIGHT_COLOR_PINK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//What we're currently using, not what we're being granted by the ai data core
var/list/cpu_usage
var/list/ram_usage
var/free_ram = 0

var/completed_projects

Expand All @@ -28,7 +29,7 @@


/datum/ai_dashboard/proc/is_interactable(mob/user)
if(IsAdminGhost(user))
if(user?.client?.holder)
return TRUE
if(user != owner || owner.incapacitated())
return FALSE
Expand Down Expand Up @@ -56,6 +57,7 @@

data["current_cpu"] = GLOB.ai_os.cpu_assigned[owner] ? GLOB.ai_os.cpu_assigned[owner] : 0
data["current_ram"] = GLOB.ai_os.ram_assigned[owner] ? GLOB.ai_os.ram_assigned[owner] : 0
data["current_ram"] += free_ram

var/total_cpu_used = 0
for(var/I in cpu_usage)
Expand Down Expand Up @@ -207,6 +209,7 @@

/datum/ai_dashboard/proc/run_project(datum/ai_project/project)
var/current_ram = GLOB.ai_os.ram_assigned[owner] ? GLOB.ai_os.ram_assigned[owner] : 0
current_ram += free_ram

var/total_ram_used = 0
for(var/I in ram_usage)
Expand Down Expand Up @@ -260,6 +263,8 @@
/datum/ai_dashboard/proc/tick(seconds)
var/current_cpu = GLOB.ai_os.cpu_assigned[owner] ? GLOB.ai_os.total_cpu * GLOB.ai_os.cpu_assigned[owner] : 0
var/current_ram = GLOB.ai_os.ram_assigned[owner] ? GLOB.ai_os.ram_assigned[owner] : 0
current_ram += free_ram


var/total_ram_used = 0
for(var/I in ram_usage)
Expand Down Expand Up @@ -299,6 +304,8 @@
cpu_usage[project_being_researched] = 0
continue
if(has_completed_project(project.type)) //This means we're an ability recharging
if(!project.ability_recharge_cost) //No ability, just waste the CPU
continue
project.ability_recharge_invested += used_cpu
if(project.ability_recharge_invested > project.ability_recharge_cost)
owner.playsound_local(owner, 'sound/machines/ping.ogg', 50, 0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/obj/machinery/computer/ai_server_console
name = "\improper AI server overview console"
desc = "Used for monitoring the various servers assigned to the AI network."
req_access = list(ACCESS_RD)

icon_keyboard = "tech_key"
icon_screen = "ai-fixer"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/obj/machinery/computer/ai_resource_distribution
name = "\improper AI system resource distribution"
desc = "Used for distributing processing resources across the current artificial intelligences."
req_access = list(ACCESS_ROBOTICS)
circuit = /obj/item/circuitboard/computer/aifixer
req_one_access = list(ACCESS_RD, ACCESS_NETWORK)

icon_keyboard = "tech_key"
icon_screen = "ai-fixer"
light_color = LIGHT_COLOR_PINK
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/datum/ai_project/security_hud
name = "Advanced Security HUD"
description = "Using experimental long range passive sensors should allow you to detect various implants such as loyalty implants and tracking implants."
research_cost = 1000
research_cost = 1250
ram_required = 2
research_requirements_text = "None"
category = AI_PROJECT_HUDS
Expand Down Expand Up @@ -29,7 +29,7 @@
/datum/ai_project/diag_med_hud
name = "Advanced Medical & Diagnostic HUD"
description = "Various data processing optimizations should allow you to gain extra knowledge about users when your medical and diagnostic hud is active."
research_cost = 750
research_cost = 1000
ram_required = 1
research_requirements_text = "None"
category = AI_PROJECT_HUDS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/datum/ai_project/camera_speed
name = "Optimised Camera Acceleration"
description = "Using advanced deep learning algorithms you could boost your camera traverse speed."
research_cost = 500
research_cost = 250
ram_required = 1
research_requirements_text = "None"
category = AI_PROJECT_CAMERAS
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/datum/ai_project/coolant_manager
name = "Enhanced Coolant Management"
description = "Dedicating processing power to figuring out the optimal way to cool our hardware should allow us to increase the temperature limit of our hardware by 10C."
category = AI_PROJECT_EFFICIENCY

research_cost = 2250
can_be_run = FALSE

/datum/ai_project/coolant_manager/finish()
if(GLOB.ai_os.temp_limit == AI_TEMP_LIMIT) //Limit to only 1 AI doing it.
GLOB.ai_os.temp_limit += 10

Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@


/datum/ai_project/examine_humans
name = "Examination Upgrade"
description = "Using experimental image enhancing algorithms will allow you to examine humans, albeit you won't be able to point out every detail.."
research_cost = 2500
ram_required = 3
research_cost = 4000
ram_required = 4
research_requirements_text = "Advanced Security HUD & Advanced Medical & Diagnostic HUD"
research_requirements = list(/datum/ai_project/security_hud, /datum/ai_project/diag_med_hud)
category = AI_PROJECT_SURVEILLANCE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/datum/ai_project/firewall
name = "Download Firewall"
description = "By hiding your various functions you should be able to prolong the time it takes to download your consciousness by 2x."
research_cost = 1000
research_cost = 1500
ram_required = 2
research_requirements_text = "None"
category = AI_PROJECT_MISC
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/datum/ai_project/induction_basic
name = "Bluespace Induction Basics"
description = "This research functions as a prerequisite for other induction research such as remote borg charging and APC emergency power."
research_cost = 3000
research_cost = 1500
ram_required = 0
research_requirements_text = "None"
can_be_run = FALSE
Expand All @@ -10,7 +10,7 @@
/datum/ai_project/induction_cyborg
name = "Bluespace Induction - Cyborgs"
description = "This ability will allow you to charge any visible cyborgs by 33%"
research_cost = 3000
research_cost = 2500
ram_required = 0
research_requirements_text = "Bluespace Induction Basics"
research_requirements = list(/datum/ai_project/induction_basic)
Expand Down Expand Up @@ -39,7 +39,7 @@
/datum/ai_project/induction_apc
name = "Bluespace Induction - APCs"
description = "This ability will allow you to charge any visible APCs by 33%"
research_cost = 3000
research_cost = 2500
ram_required = 0
research_requirements_text = "Bluespace Induction Basics"
research_requirements = list(/datum/ai_project/induction_basic)
Expand Down
Loading