Skip to main content

Module ai

Module ai 

Source
Expand description

CitizenAIComponent: choosing what a citizen does next. See docs/CITIZEN-AI.md.

Original: FUN_140115040.

Modules§

activity
Activities.

Structs§

CitizenAi
A citizen’s AI: the cooldown of each activity, the current and queued activity, and the urgent flags.
CitizenView
The citizen values candidate building reads (D = CitizenDescription).
Thresholds
The CitizenDescription thresholds candidate building reads.

Functions§

candidates
Candidate activities in push order, and whether the list is shuffled and sorted (the doctor-only and urgent-only lists return before that).
crt_qsort
The MSVC CRT qsort inlined for candidates, ordering by priority, highest first (comparator b.priority - a.priority). Median of three, short sort (selection of the maximum) for 8 or fewer elements, smaller partition first.
crt_qsort_by
The same with a three-way comparator.
crt_qsort_less
The Microsoft C runtime’s qsort with a less comparator, as the game’s templated copies use it: the same algorithm as crt_qsort_by, with cmp(a, b) > 0 being less(b, a) and equality neither way.
shuffle_and_sort
Swap each position with Rand(count), then sort.

Type Aliases§

Candidate
One candidate (12-byte entries: activity, priority, unused).