Skip to content

(do not merge) - used to see diff between AdvCiv-SAS and base AdvCiv 1.14 - #39

Open
wonderingabout wants to merge 2213 commits into
1.14from
main
Open

wonderingabout wants to merge 2213 commits into
1.14from
main

Conversation

@wonderingabout

Copy link
Copy Markdown
Owner

continuation of PR #13 now that tech-rework has been renamed to main, and then of PR #34 now that Base AdvCiv latest upstream branch is as of now 1.14

@wonderingabout
wonderingabout force-pushed the main branch 27 times, most recently from 92741da to 202064c Compare August 26, 2026 08:00
@wonderingabout
wonderingabout force-pushed the main branch 3 times, most recently from 0efbadc to 74fe70f Compare August 27, 2026 19:29
wonderingabout and others added 30 commits October 13, 2026 08:37
…ging is disabled; refactor UWAI diagnostics into XML-tunable BBAI logging

- Continue the inherited diagnostic cleanup begun with the AdvCiv Found logging repair/refactor in KI#505.2.
  - UWAIReport suppressed formatting/output inside its muted sink, after C++ callers had already evaluated logging arguments and entered helpers.
  - Disabled reports therefore still incurred diagnostic name/string preparation, argument calculations and helper-call overhead, notably in the hot WarUtilityAspect path.
  - Pre-gate diagnostic calls and logging-only setup at their callers using startup-cached category levels, while retaining normal AI calculations regardless of logging.
- Consolidate UWAI diagnostics into the existing BBAI infrastructure.
  - Retire UWAIReport.cpp/.h, standalone per-turn uwai<turn>.log files and their Textile-oriented report machinery.
  - Use the shared timestamped BBAI stream, session/settings provenance and literal-safe final output boundary instead of maintaining a parallel logger.
  - Replace report plumbing with UWAILogMuteState.h, which retains only nested mute depth so speculative internal passes can remain silent without losing an outer mute.
  - Update the Visual Studio project and affected UWAI evaluator/simulation interfaces; remove the dedicated WarUtilityAspect report helper.
- Add five independently controlled, startup-cached XML logging categories under the existing BBAI master switch.
  - SAS_BBAI_UWAI_AGENT_LOG_LEVEL
  - SAS_BBAI_UWAI_MILITARY_ANALYST_LOG_LEVEL
  - SAS_BBAI_UWAI_INVASION_GRAPH_LOG_LEVEL
  - SAS_BBAI_UWAI_ARMAMENT_FORECAST_LOG_LEVEL
  - SAS_BBAI_UWAI_WAR_UTILITY_LOG_LEVEL
  - Include these categories in the cached any-enabled check and BBAI settings profile; commit disabled defaults rather than local autoplay logging settings.
  - Retire REPORT_INTERVAL, UWAI_REPORT_THRESH, UWAI_REPORT_THRESH_HUMAN and DISABLE_UWAI_REPORT; explicit category levels now control diagnostic scope without separate interval/threshold or compile-time switches.
- Keep diagnostic observation separate from gameplay, including synchronized RNG and cache behavior.
  - Select the gameplay utility from the original naval/non-naval comparison; a later logging-only rerun cannot replace that result.
  - Route selected-scenario diagnostic reruns through evaluateForDiagnostics, which returns no utility to gameplay and bypasses WarEvaluator cache reads/writes and focused structured WAR diagnostics.
  - Preserve the ordinary gameplay evaluator and its cache semantics for callers such as UWAICache.
  - Restrict extra selected-scenario detail passes to enabled level-2+ categories; level 1 remains compact and avoids that diagnostic-only rerun cost.
  - Preserve KI#517's synchronization of global and Team-local background states in the manual diagnostic helper; its output now follows the normal category levels rather than forcing the retired report sink.
  - Logging should observe the AI without changing the decisions or random sequence being investigated. This is diagnostic isolation and reproducibility work, not a claim of repairing a demonstrated multiplayer OOS bug.
- Preserve provenance and explain the resulting architecture.
  - Document KI#505.3 as a later cross-file caller-side defect; retain the historical C++ File Audit Album's completed file-local UWAIReport audit rather than rewriting its scope or conclusion.
  - Clarify that KI#431's inherited missing-vararg defect was fixed previously and that this refactor later retires its affected report formatter.
  - Update the Main Changes Guide with the broad benefits, retired/replacement files, category usage and an indicative high-detail log size; keep detailed validation history in Known Issues.
  - Add nearby KI references and general agent guidance for caller-side gating, observation-only reruns and avoiding unnecessary diagnostic string aggregation.
- Validate the refactor with full-run diagnostic evidence and source checks.
  - The latest two revision-137 records, SASGameRecord_20261008T185338Z_load1.log and SASGameRecord_20261008T194930Z_load1.log, contain 399 identical authoritative RNG checkpoints and 399 identical semantic CORE checkpoints, reaching the same turn-394 Space Race result.
  - Comparisons against earlier source builds also match CORE state but differ in RNG call-provenance fingerprints; those comparisons are not described as exact whole-checkpoint matches.
  - All five UWAI categories at level 3 produced 1,352,225,239 bytes of BBAI output, approximately 1.26 GiB: intentionally detailed diagnostic output rather than compact whole-game history.
  - Recorder contracts, SAS define usage, repository hygiene, diagnostic sink safety, Markdown structure and Markdown lint checks pass; staged logging defaults are disabled.
  - Workflow tests pass 89/90; the sole failure comes from pre-existing orphan Long_Comments markers in an ignored deferred XML draft, outside this change.
- Keep separate follow-ups out of this commit.
  - The iterable BBAI category registry remains deferred: consolidating repeated loading/enabled/profile lists is a distinct configuration-maintenance refactor that can preserve the current cheap direct call-site guards.
  - A systematic conversion of remaining inherited prose into stable UWAI event identifiers with explicit team/target/scenario context remains separate; this commit establishes unified output and gating without claiming the complete greppable-message modernization is finished.
  - Do not add SASGameRecord fields or increment revision 137: this change modernizes BBAI/UWAI diagnostics without changing recorder implementation or schema.
  - Do not change AI valuation/balance rules, add save compatibility handling or include local autoplay logging settings.
- Update DLL with the rebuilt Release binary.
- Identify current versus detected default-branch state without hardcoding the branch name or fetching.
  - Report local/remote tips, development counts and exclusive ancestry; export both sides of divergent history with full SHAs, parents and messages while hiding author emails.
  - Explain repeated counts and cherry-pick identities; anchor comparisons to one verified shared ancestor and report unavailable/ambiguous bases explicitly.

- Provide cumulative committed-only and complete tracked working-tree patches against the same shared ancestor, alongside separate staged/unstaged patches.
  - Filter CRLF/LF and trailing-whitespace noise while preserving meaningful indentation/content changes without rewriting source files or reversing default-only commits.
  - Report patch paths, scopes, change counts and filenames for small lists; explain partially staged files.

- Include exact default-tip, pre-edit HEAD and captured index reference files under their original repository paths.
  - Preserve filenames, extensions, encoding and Git blob bytes for direct baseline and HEAD -> index -> working-tree review without reconstructing patches.
  - Record missing/deleted/renamed counterparts, captured index identities, binary exclusions and size limits without modifying the index.

- Report exact sizes, SHA-256 hashes and byte comparisons for omitted tracked DLLs at default, HEAD, index and working state.
  - Keep binary payloads excluded; make missing baselines, read failures and changes during hashing explicit. Timestamps and sizes do not establish functionality or Release/Debug-opt configuration.

- Expose history-cache reuse, regeneration and ZIP-writing progress, including guidance for long first-time rebuilds.
  - Present history/cache/upstream details on logical console/archive lines.
  - Report UTC timestamps with milliseconds, monotonic duration and observed Windows game/IDE/build processes; persistent MSBuild workers do not establish an active build.
  - Archive the pre-write packaging summary with comparison state, change lists, options and history coverage; final completion time and ZIP size remain console-only.

- Document the review layers, EOL filtering, output example and observed Visual C++ 2010 opensdf packaging lock in existing helper/overview guides.
  - Keep the concise command-output example beside the usage instructions and distinguish it from the generated ZIP artifact. Source review complements compilation and runtime testing.

Validation across these tooling changes: generated ZIP and synthetic Git checks for patch coverage, default-only isolation, EOL suppression, exact reference bytes and two-sided history; committed/working separation on main; process/branch metadata checks; packaging dry run; four history-filtering tests; repository hygiene, Markdown structure and markdownlint.

Developed during the UWAI diagnostics restructuring into structured BBAI logging and brought to main independently of the ongoing diagnostic-code changes.
)

- Modernize the inherited UWAI narrative diagnostics after the KI#505.3 migration to XML-tunable BBAI logging.
  - Cover WarEvaluator scenario analysis, MilitaryAnalyst results, ArmamentForecast inputs/results, InvasionGraph topology/combat, UWAIAgent decisions and the full WarUtilityAspect diagnostic surface.
  - Use 331 unique UWAI_* event identifiers with explicit participant, scenario, calculation and outcome fields.

- Consolidate related scalar calculation stages into self-contained result rows instead of emitting one event per inherited prose sentence.
  - Preserve genuine one-to-many detail for cities, allies, enemies, military branches and graph components.
  - Combine production inputs, actual/estimated typical-unit state, city-combat power, component isolation, capitulation-delay probability/outcome and vassal-acceptance utility.
  - Reduce the final cross-file diagnostic surface from 343 event sites to 331 while retaining useful calculation context.

- Keep diagnostic work separate from gameplay and cheap when disabled.
  - Pre-gate logging-only formatting, traversal, rounding and context preparation at callers; reuse level/mute checks where appropriate after irrelevant early returns.
  - Reuse exact gameplay decisions and intermediate results, including the capitulation-delay RNG result and distrust value, rather than recomputing them for logging.
  - Preserve truthful sentinel values, nested mute behavior and observation-only selected-scenario reruns without changing evaluator cache semantics.
  - Replace remaining UWAI stream aggregation with direct structured rows and remove stale free-form diagnostic code.

- Preserve the existing distinction between detailed BBAI reasoning and compact SASGameRecord history.
  - Add no recorder schema fields: selected/realized war-plan, peace, vassalage and strategic history are already recorded; exhaustive candidate and hypothetical reasoning remains in BBAI.
  - Keep LoveOfPeace unchanged because it had no inherited diagnostic prose to convert, and leave the iterable BBAI category registry and unrelated older loggers for separate work.

- Update KI#505.3 and the main changes guide with the completed diagnostic contract, historical intermediate results and final validation.
  - The final all-five-category level-3 run produced 2,681,295,993 bytes of BBAI output, about 2.50 GiB.

Validation: successful Debug-opt compilation and full same-save autoplay through turn 394 with the same Space Race victory. Compared with the preceding full run, all 394 turn-complete rows, 399 RNG checkpoints, 44 run-status rows, 1,869 victory-progress rows, 623 AI victory-stage snapshots and 183 stage changes match exactly. All 399 semantic CORE checkpoints match after excluding only computeMilliseconds. This supports unchanged gameplay and synchronized RNG in the tested run. Logging safety, message-style tests, unique event identifiers and diff whitespace checks also pass.
- Pair each BBAI log-level XML define with its existing cached settings field in one category registry.
  - Drive startup loading/clamping, cached enabled-category detection and BBAI_LOG_SETTINGS output from the shared registry instead of three parallel lists.
  - Preserve the settings layout, direct cached caller guards, log-level semantics and profile category order.
- Extend the SAS define-usage checker to recognize runtime registry lookups.
  - Require a comment-free lookup consumer and reject inert tables, commented-out consumers and string-only consumers through regression coverage.
- Document the shared maintenance registry in the Main Changes Guide and clarify the existing outer startup logging gates.

Validation:
- 19 define-usage regression tests pass; repository define-usage and Markdown structure checks pass.
- User reports successful compilation and an autoplay through turn 11 without observed problems.
- Separate 215 preserved comments from collapse_cpp_signatures.py's generated custom hoist-trace markers across the current C++ source.
- Keep inherited or previously custom comment text unchanged on its own line so generated provenance cannot make legacy wording appear newly authored.
- Update all traced whole-line, block and inline-comment hoist paths to emit the preserved comment and custom provenance as separate physical lines.
- Keep trace-only hoists as a single custom provenance line when there is no preserved comment payload.
- Update the helper documentation, example and command-line descriptions to document the separated output format.
- Remove the completed provenance-cleanup item from the temporary changes checklist.
- Remove 16 trailing Markdown hard breaks immediately before a blank line or end of file across maintained documentation.
- Teach the Markdown structure checker to reject redundant final hard breaks.
  - Ignore escaped literal backslashes, fenced code, inline code and HTML comments.
  - Preserve inline-code content when checking whether the following line is blank, avoiding false failures for valid hard breaks.
- Update menu regeneration so the final non-bullet menu row no longer receives an unnecessary trailing backslash.
- Add regression coverage for detection, menu regeneration, escaped backslashes, code/comment exclusions and end-of-file handling.

Validation:
- All 41 CI-backlog tests pass.
- Full maintained-document Markdown structure scan and whitespace checks pass.
- Collapse 19 diagnostic logging guards across eight DLL source files while preserving conditions, arguments and evaluation order.
- Expand the helper to recognize existing logging flags and logger-enabled predicates.
- Preserve multiline conditions as a crash-investigation exception: separate source lines help distinguish failing predicate accesses from logging-argument evaluation.
- Continue skipping semantic-only guards, multi-statement bodies, ambiguous calls and braced if/else chains.
- Add regression coverage for gate recognition, preserved multiline conditions, conservative skips and idempotence.
- Verify all six helper tests pass and a full 351-file rescan finds no further eligible collapses.
- Reorganize AdvCiv-SAS custom prose comments across C++, Python and XML at sentence/clause boundaries instead of arbitrary width targets.
  - Join physical wraps within a sentence, separate substantial sentences and keep closing credits, KI references and other provenance attached to the relevant thought.
  - Preserve existing technical wording and inherited comments; leave structured or ambiguous material for manual review.
- Add a reusable conservative reflow helper and document its audit, preview and apply modes.
  - Preserve source encoding and newline style, verify Python token equivalence before writing, and skip code-like, structured or malformed comments.
  - Record the logical comment-layout convention in AGENTS.md.
- Advance SASGameRecord to revision 138 for recorder-related implementation, declaration, call-site and checker comment updates.
  - Add its history entry and resolve revision 137's introducing commit reference; emitted fields and recording behavior are unchanged.
- Add six regression tests protecting technical text, credits/KI references, inherited and structured comments, XML data, Python tokens, final-newline handling and idempotence.

Validation:
- Existing C++ and Python source token comparisons preserve code; the only XML change outside comments removes a trailing tab.
- Six reflow tests, recorder revision synchronization, Markdown structure and text line-ending checks pass.
- User reports successful DLL compilation.
- Compare maintained C++/Python/XML changes with the selected Git base rather than imposing new provenance rules on unchanged historical source.
  - Flag new untagged prose, silent inherited-comment rewrites and dropped provenance references while allowing reflow, moved comments, stale-comment removal and required boilerplate.
  - Require nearby custom rationale for dependency edits and changed non-SAS function parameters in existing files; clearly SAS-named helpers and wholly new-file dependency lists retain their documented exceptions.
- Keep missing model credits advisory because Git cannot distinguish user-authored uncredited comments from model-authored comments.
  - Use plain model-credit terminology and preserve the user's optional self-credit convention.
- Run the custom-comment logical reflow check automatically across maintained source.
  - Fail on eligible sentence/clause reflow changes, name affected files and leave source untouched; retain structured/code-like/ambiguous blocks as explicit skips.
  - Repair the remaining eligible test-header comment and document local preview/apply commands.
- Consolidate header-specific guidance into the general C++ declaration/definition, dependency and compilation-pitfall rules.
- Add regression coverage for provenance failures and read-only reflow enforcement, including actual Git/CLI exit codes and advisory-warning behavior.

Validation:
- All 18 provenance tests and seven reflow tests pass.
- Full reflow scan covers 869 files with no eligible changes remaining.
- Provenance, Markdown structure and whitespace checks pass.
- Reuse the existing prose helper to identify sentence boundaries, with a 400-character candidate threshold and at least 100 characters on each side of a proposed split so short headings and follow-ups stay attached.
- Enforce the rule only for added or edited Markdown blocks. Soft newlines still count as one paragraph; use coherent blank-line paragraphs or child bullets rather than one paragraph per sentence.
- Preserve exemptions for single long sentences, code, tables, blockquotes, HTML comments and archived/generated references. Report all affected paths and lines without rewriting documents.
- Restructure long blocks across maintained documentation while preserving wording, headings and code; retain related sentences together and document the limits of automatic reflow.
- Add ten regression tests covering the threshold, short follow-ups, soft-wrap bypasses, protected contexts and real Git/CLI failure-and-repair behavior. Use Git hunks to avoid slow repeated-line matching in large histories.
…ays (KI#144.2)

- Add a separate continue-versus-settle gate for first-city scouting without changing the existing scouting-direction score.
- Derive remaining scouting opportunity from the best known best-6/best-10 capital core against the XML-derived sustainable productive-plot reference, so strong known capitals naturally have less plausible upside while poor starts remain worth investigating.
- Discount uncertain fog information by that remaining opportunity and scale scouting delay cost by both elapsed share of the configured scouting window and settle-now core quality.
- Keep early scouting cheap, progressively raise the bar near the deadline, and avoid terrain, resource, river, civilization, map or raw found-value cutoffs.
- Add detailed Settler BBAI diagnostics for raw/discounted information, remaining opportunity, settle-now core quality, time pressure, expected gain and low-upside stop/return outcomes.
- Fix the Korea case so it still discovers and settles the strong Maize + Pig capital at (47,25), but founds on turn 5 instead of spending two additional turns on marginal fog scouting.
- Validate with a five-map SAS48 turn-11 autoplay suite covering 240 identical starts: 230/240 kept the exact same capital tile and founding turn, aggregate founding timing remained effectively unchanged, and no clear site-quality regression appeared.
- Document the behavior, rejected first attempt and regression evidence as KI#144.2 and update the main changes guide.
…er diagnostics

- Preserve realized first-city Settler scouting without duplicating BBAI rejected-candidate spam:
  - record the initial stronger-growth-core investigation;
  - record subsequent chosen first-city scouting steps with settle-now quality, information/upside and delay context;
  - record scouting termination from the deadline, low expected upside or absence of a safe step.
- Record later promising-fog Settler detours that use MISSIONAI_EXPLORE and therefore bypass ordinary Settler-site assignment telemetry.
- Add rare level-3 loaded-transport defender-selection diagnostics with the chosen defender and best alternative, including damage, experience, cargo, Lead From Behind ranking/value and healer/defensive context.
  - Keep this observational because transported cargo is already excluded from defender candidates and inherited K-Mod Lead From Behind already protects loaded transports.
  - Conceptually motivated by the reported Civ4 escort-selection case: https://www.reddit.com/r/CivIV/comments/1x1r0i3/escorting_transport_ships/
- Advance SASGameRecord to revision 139.
- Runtime-test first-city and later promising-fog Settler rows through a Korea autoplay; seven later-city fog-scout rows were observed.
- Reuse available best-6/best-10 growth-core values from the same first-city evaluator when the continuation target is the identical current or best-known plot. Evaluate other targets normally; no persistent cache is added and gameplay scoring remains independent of logging.
- Maintain expected-gain summaries and the optional linear-opportunity output only when Settler BBAI level 2+ or SASGameRecord level 2+ consumes them. Preserve both consumers and the existing recorded fields.
- Document the optimization in KI#144.2, distinguish it from the earlier autoplay results, and preserve joint ChatGPT-5.6-Sol and GPT-6.1-Sol credit.
- Advance SASGameRecord to revision 140 for the shared logging bookkeeping change, keep its history entry recorder-focused, and finalize revision 139's commit reference.

Validation: source-change provenance, revision ancestry, Markdown prose/structure/lint, custom-comment reflow and staged whitespace checks pass. The recorder checker reports only the intentionally enabled local logging level; local DLL and XML settings are excluded. Compilation and autoplay validation of this follow-up are pending.
- Advance SASGameRecord to revision 141.
- Embed a compact save-checkpoint identity into the serialized copy of game script data without changing Python-visible script data or creating any additional saves.
- Preserve the saved turn, elapsed turn, UTC timestamp and authoritative map/sync RNG states so a later load can identify the exact serialized checkpoint within its game lineage.
- Emit matching GAME_RECORD_SAVE_CHECKPOINT_SERIALIZED and GAME_RECORD_SAVE_CHECKPOINT_LOADED rows while keeping checkpoint persistence independent of whether SASGameRecord logging was enabled when the save was created.
- Keep native/manual save filenames explicitly unknown because Civ4 does not expose them reliably at the DLL serialization boundary.
- Pass SASFastSave's already-final basename and reason into the one-shot save context so START/STOP/END/victory saves can later identify their exact original filename without duplicating filename construction in C++.
- Preserve SASFastSave as the sole filename authority, including UTC naming and collision suffixes.
- Validate the full save/load round trip with a Wang Kon STOP save: the loaded checkpoint reproduced the exact serialized checkpoint ID, turn, UTC, RNG states, reason and original basename.
- Diagnose first-capital food capacity through Found level-3 logging:
  - Report F/P/C capacity and food surplus for value-ranked best-6/10/14 plot cores, food-ranked selected improvements, and natural-food-ranked alternatives.
  - Include natural F/P/C for the value-ranked cores to distinguish mature potential from unimproved capacity.
  - Retain existing features, including Jungle, in natural-yield samples; use settled city-center yields and known-resource visibility.
  - Food-ranked potential reorders the evaluator's selected improvements; it does not claim an absolute maximum-food configuration or immediate technology availability.

- Expose the current resource classifications and scoring inputs:
  - Record starting-food resource classification, improved food capacity, and inland-water classification.
  - Compare the generic happiness/health component with full dynamic and separately applied non-yield resource scores.
  - The component is independently rounded diagnostic evidence, not an exact decomposition or a scoring subtraction.

- Observe known resources immediately outside the workable BFC:
  - Include ownership, rival future BFCs, duplicate types, trade/improvement access, and reference values.
  - These observations grant no outer-ring resource credit.

- Preserve diagnostic evidence while deferring the provisional Bibracte resource/scoring cure:
  - Broader cure tests exposed a Wang Kon scouting regression.
  - Keep the evidence needed to understand current choices before changing resource weights or scouting behavior.
  - Link the existing KI#144.2 screenshot/save evidence folder for the scouting regression guard.

- Pre-gate additional yield sampling, resource scans, component calculations, allocations, sorting, and formatting behind Found level 3.
  - Existing scoring, classification, and first-city scouting rules remain unchanged.
  - This commit does not extend SASGameRecord or introduce gameplay defines.

Validation:
- User-reported successful DLL compilation.
- Source-change provenance, custom-comment reflow, and whitespace checks pass.
- The logging audit adds no findings relative to the parent commit; the source diff preserves every existing scoring line.
- Six focused reruns completed turn 10 and reproduced the expected pre-cure capital outcomes:
  - Bibracte (77,36), Nidaros (87,59), and Istanbul (87,33).
  - Persepolis (35,49), Aachen (137,72), and Seoul (47,25); Seoul was founded on turn 5.
- Sampled BBAI logs contain all five added diagnostic categories, including natural/potential capacity fields.
- PythonErr.log is empty.
- These checks establish the targeted founding baseline, not a full RNG/state-equivalence proof.
…KI#178.2)

- Following the KI#144.2 first-city scouting investigation and its later diagnostic pass, fix an AdvCiv-SAS interaction between KI#178's settlement-specific resource valuation and practical 6577's shared dynamic bonus valuation.
- KI#178/practical 6025 replaced broad trade-style AI_bonusVal settlement scoring with explicit long-term resource health/happiness and ordinary early-building value. Practical 6577 later replaced the static iAIObjective strategic add-on with dynamic AI_baseBonusVal so resource importance could reflect civilization-specific units, buildings, projects, routes, obsolescence and substitutes.
- AI_baseBonusVal also contains a generic no-city happiness/health component, so actual first-capital scoring was applying that component on top of KI#178's explicit settlement-specific resource value.
- Remove only that overlap for actual first-capital evaluation. Subtract the original scaled happiness/health subtotal before the shared divisor and final rounding, while preserving unit, building, project, route and manual AIObjective value. Normalization and later-city scoring continue to use the full dynamic value.
- Cache the exact no-overlap remainder separately with the existing bonus-value invalidation boundaries, discard/recompute it after loading without adding save fields, and preserve multiplayer eager-refresh behavior.
- Retain Found-level diagnostics exposing the full dynamic value, generic happiness/health component, strategic remainder and exact score removed.
- SAS48 validation:
  - Mehmed now prefers the healthier Istanbul river site at (86,32), 3876 vs 3792.
  - Wang Kon still scouts west and founds Seoul at (47,25) on turn 5.
  - Bibracte remains at (77,36), while its lead over (78,36) narrows from 901 to 451.
  - Nidaros and Persepolis remain unchanged.
- Document the issue as KI#178.2 and link it back to the KI#144.2 diagnostic follow-up. Source archaeology identifies this as an AdvCiv-SAS regression caused by the interaction of practical 6025/KI#178 and practical 6577, not an inherited BtS/K-Mod/AdvCiv defect.
- Also clarify AGENTS.md build-status guidance so a lingering MSBuild process alone is not mistaken for an active user-started Visual C++ 2010 Express compile.
…I#144.3)

- Refine AdvCiv-SAS's KI#144 Update 2 classifier after the KI#144.2 diagnostic investigation and KI#178.2 resource-overlap fix.
  - The earlier rule fixed Elephants and unusable inland seafood, but still awarded the capital growth premium whenever a land resource improvement added any Food.
  - Weak 2-3 Food tiles could therefore receive the same premium as strong growth resources.

- Require the mapped resource improvement to add Food and the improved plot to feed the citizen working it plus one additional citizen.
  - Derive the threshold from 2 * FOOD_CONSUMPTION_PER_POPULATION rather than hardcoding 4 Food or resource identities.
  - Preserve terrain-sensitive qualification and the coastal-city requirement for water resources.
  - Measure eventual improved capacity under existing evaluator assumptions, not immediate technology or improvement availability.

- Preserve ordinary improvement-yield scoring and isolate this layer from inland-water, outer-ring and scouting policy changes.
  - Found level 3 compares the previous and new classifications, the improved Food capacity and the growth threshold.
  - Document the SAS-specific follow-up, provenance and representative evidence as KI#144.3.
  - Organize KI#144's updates as subsections and record their Git-verified chronology.

Validation:
- The six-case autoplay review supplied in ChatGPT's discussion reports only food-to-non-food classification changes; stronger qualifying tiles retain their growth premium.
- Bibracte's 3 Food Spices loses exactly 90 points of extra growth premium; Bibracte remains at (77,36).
- Wang Kon still scouts west and founds Seoul at (47,25) on turn 5.
- Istanbul retains the river site (86,32), scoring 3876 versus 3792 for the Gold/Grapes alternative.
- Nidaros and Persepolis remain unchanged; Charlemagne keeps (136,72), while the competing site's 3 Food Sugar loses the same 90-point premium.
- Markdown lint/structure, source-change provenance, diagnostic log safety, custom-comment reflow and whitespace checks pass.

Developed and reviewed with ChatGPT-5.6-Sol and GPT-6.1-Sol.
… (KI#128.2)

- Remove four inherited AdvCiv static caches from nuclear unit-damage and building-destruction calculations.
  - Their enum-backed getters already read CvGlobals' shared integer cache; use ordinary per-explosion locals so explicit runtime define updates are reflected.
  - Preserve the formulas and RNG calls when define values remain unchanged.

- Remove the similar SAS-added MIN_WATER_SIZE_FOR_OCEAN static from the KI#186 city-retention evaluator.
  - Read the already cached engine value once per evaluation.
  - Leave session-fixed SAS tuning and expensive derived caches unchanged.

- Replace SAS-added persistent screen caches for food consumption and commerce increments.
  - The Domestic Advisor reads food consumption through the DLL's cached integer getter on each row refresh.
  - Domestic Advisor, Foreign Advisor and Main Interface read the commerce increment once per control redraw and reuse it for both +/- buttons.
  - Explicit runtime updates become visible on the next relevant refresh without recreating the screen.

- Document the inherited risk and related SAS follow-ups as KI#128.2, with a brief Main Changes Guide entry and greppable code references.
  - This addresses stale values after code-driven define changes; it does not enable live XML-file editing or claim a reproduced normal-gameplay nuclear bug.
  - Reserve new sequential KI numbers for the audit album; use relevant unused decimal follow-ups starting at .2 for other findings.

Validation:
- User confirmed successful DLL compilation and an in-game smoke test with no obvious issue.
- Focused mocked checks verify food-consumption totals and both commerce-button increments reflect updated values.
- Edited UI files pass a Python-2 grammar parse.
- Markdown lint/structure, source-change provenance, custom-comment reflow and whitespace checks pass.
- Explicit runtime define-change and nuclear-effect tests remain pending.
…KI#647.2)

- Derive five AI and map-generation checks from FOOD_CONSUMPTION_PER_POPULATION instead of assuming two Food.
  - Update inherited building specialist-support estimates and SAS's one-extra-specialist civic estimate.
  - Update inherited Advanced Start fertile-terrain checks, normalization's Food-feature preservation cutoff, and K-Mod's weak-surroundings Food threshold.
  - Read the current shared-cache getter without introducing process-lifetime caches; preserve calculations and comparisons at the default consumption of two.

- Preserve separate balance heuristics rather than mechanically replacing every Food-related constant.
  - Leave mixed-yield scoring weights, growth-speed surplus targets, tailored weak-resource cutoffs and historical diagnostic comparisons unchanged.
  - Non-default consumption can alter normalization decisions and subsequent map-generation RNG progression.
  - Keep the existing weighted inland-water classification and observation-only diagnostics; the experimental blanket inland-water override is not included.

- Keep Found event identifiers and their payload format together, and join selected BBAI format strings without changing emitted text.
  - Retain the grouped layout of the exceptionally long crowded-city attack-movement row and preserve complex argument lists below the format strings.

- Document the scope and exclusions in KI#647.2 and summarize the change in the Main Changes Guide.
  - Album F324 / KI#647 discusses the same civic-estimation block but identifies independent shared-citizen double counting; that defect remains pending.

Validation:
- Checked inherited source provenance against local base AdvCiv and the SAS civic-estimator history.
- Arithmetic checks cover default and non-default consumption; verified restoration of the original inland-water classification block.
- Markdown lint/structure, source-change provenance, custom-comment reflow and whitespace checks pass.
- Compilation and in-game validation of this follow-up remain pending.
…isions

- Compare the existing natural-Food heuristic with optimistic, technology-discounted Food relief from the ordinary-land improvement already selected by the evaluator; keep the gameplay penalty unchanged.
- Find the highest workable-yield value supportable by Food at 6, 10 and 14 non-home workers, accounting for the free city center and exact signed Food totals without reusing plots.
- Add a separate projection through AdvCiv's first-capital rank weighting plus worked resource-improvement yield; retain both comparisons because their objectives can select different plot subsets.
- Exclude resource-access benefits from the constrained worked value and label health, happiness, technology and growth-path limitations explicitly. The projected difference is a partial diagnostic score, not a final found-value penalty.
- Keep subset searches, sorting, formatting and rank-multiplier precomputation behind Found level 3 for actual first-capital evaluations. Preserve gameplay scoring, scouting decisions and RNG.
…scoring (KI#144.4)

- Account for the Food needed to work attractive Gold Hills, productive Grassland Hills and other low-Food plots together. When supporting their citizens requires switching to lower-value Food-rich plots, reduce the projected worked-core value by that opportunity cost.
  - Low-Food plots remain useful when the city can support them; a sustainable assignment is distinct from a growth path, and this does not claim that a city can never grow to the assessed population.
- Compare Food-feasible and unconstrained rank-weighted cores at 6 and 10 non-home workers, including free city-center Food and worked resource-improvement yield.
  - Apply the larger projected gap once, never their sum; require sustainable alternatives at both stages and leave the 14-worker core diagnostic-only.
  - Leave resource-access benefits outside the Food constraint and skip the correction when the established broad low-food penalty already applies.
- Add SAS_EVALUATE_STARTING_FOOD_SUPPORT_PENALTY_PERCENT, default 100. Keep scope, gameplay and diagnostics separate: zero percent with Found logging below 3 skips capacity collection and subset searches; enabled gameplay computes only the required 6/10 projection.
  - Pregate natural-yield sampling, raw workable-value accounting, diagnostic totals, formatting and core-14 work. Reuse the projection for Found diagnostics and expose the applied foodSupport breakdown contribution.
- Document the inherited limitation within SAS's changed scoring model. Base AdvCiv had aggregate Food heuristics, but no explicit worked-core subset constraint; measured gaps are from SAS and do not establish a reproduced base-AdvCiv founding regression.
  - Preserve why the old nonlinear evaluateSpecialYields / adjustToFood paths stay disabled rather than restoring them.
  - Retain Nidaros's rejected Food-budget hypothesis, supportive Food surpluses and misleading cached 6201 versus fresh 4178 alternative score as evidence for later diagnostic/recorder review.
- Keep later-city Food-support applicability as the preferred separate investigation; do not extend fixed first-capital cores or revive the rejected outer-BFC resource-credit prototype. SASGameRecord schema remains unchanged.

- Update DLL: include the user-rebuilt Release binary for the new DLL-used XML define and first-capital Food-support scoring.

Validation:
- The supplied six-map A/B review reports identical turn/coordinates for all 256 first-city founding records. The correction applied to 323 of 15,958 deduplicated candidate states, approximately 2%; median adjustment 39, 90th percentile 186, maximum 444.
- Only two founded-site rescored values changed: Aksum 3980 to 3952 and Persepolis at (168,18) 4255 to 4224. Both locations remained selected; these runs demonstrate active, restrained scoring changes rather than a visibly improved founding location.
- Randomized model comparisons confirmed identical gameplay penalties with diagnostic core-14 processing enabled or disabled.
- Markdown lint across 25 files, Markdown structure/prose/links, SAS define usage/bounds, source provenance, caller logging gates, literal-safe sinks, custom-comment reflow and whitespace checks passed.

Developed and reviewed with ChatGPT-5.6-Sol and GPT-6.1-Sol.
- Share the existing Food-feasible projection while preserving first-capital scoring; audit ordinary later-city 3/6/10/14 worked-plot cores without changing AI scores.
- Add SAS_BBAI_FOUND_LATER_CITY_FOOD_SUPPORT_AUDIT_ENABLE, default off and requiring Found level 2+. Pre-gate collection/search/formatting and search only surviving positive candidates.
- Document the observed support gaps, replay limits and logging costs in KI#144.4. Huamanga's measured gap did not reverse its site preference, so no later-city penalty is introduced.

Developed and reviewed with ChatGPT-5.6-Sol and GPT-6.1-Sol.
…rt and fresh alternative scores

- Add revision 142 Food-support evidence for founded sites and one cached alternative, following the Settler AI investigations in KI#144.3, KI#178.2 and KI#144.4.
  - Record player-known 3/6/10/14-plot potential/natural Food budgets, selected-potential Food ranking, projected unsupported worked value and the applied capital adjustment.
  - Distinguish rejected evaluations and unavailable cores from measured zero/negative budgets; keep sustain-only, growth and technology limitations explicit.
- Rescore one cached alternative alongside its cached value and plot-value distribution so stale shortlist scores cannot masquerade as comparable fresh evaluations.
  - Reuse the founded site's existing player-known pass and evaluator cache; add at most one alternative evaluation at the existing level-2 pre-founding boundary.
  - Keep optional result storage recorder-owned, ordinary evaluations outside the added collection/search, and periodic snapshots free of additional rescoring.
- Preserve AI decisions, save serialization and RNG behavior; exhaustive rejected-candidate/resource diagnosis remains in BBAI.
- Synchronize revision history, Known Issues, the main changes guide and CI contracts with regression coverage.
- Move technology and espionage chooser contexts into SASGameRecordLog.h, leaving forward declarations in the AI headers.
- Centralize deal, trade-item and raw diplomacy-event formatting, plus deal-invalidation capture and bonus-trade bookkeeping.
- Fold Settler duplicate-destination filtering into the recorder helper while preserving pre-dispatch timing and logging gates.
- Preserve row schemas, AI decisions and logging-disabled initialization behavior; keep shared utilities and gameplay calculations at their existing sites.
- Update revision history and CI contracts. Compilation, 44 regression tests and the T250 autoplay pass; sampled state checkpoints and RNG streams match revision 142, with call-provenance fingerprints differing.
…context

- Expose distance, city-count, colony and corporation maintenance alongside actual costs, maintenance waivers and total-maintenance deltas.
- Add readable city automation flags and empire counts for zero Food surplus, assigned population specialists and their overlap, without interpreting those states as mismanagement.
- Show unit costs, supply, civic upkeep, city maintenance and inflation; reuse the existing gold-rate calculation instead of repeating its Python extra-expenses callback.
- Split the two largest recorder format strings into logical field groups without changing their output.
- Keep this observational: no AI decisions, RNG, save-format changes, UI-attention tracking or additional persistent unhappiness/production-age trackers. Existing city history and native timers already cover those latter questions.

Conceptual inspiration: a Reddit discussion about the economic and administrative burden of expanding an empire prompted a review of which factual context SASGameRecord already covered and which cost components were missing:
https://www.reddit.com/r/CivIV/comments/1x1og7s/i_conquered_an_entire_continent_in_civ_iv_and/

Validation: completed T250 autoplay; all 254 RNG and state checkpoints match revision 143. New maintenance arithmetic, aggregate counts and deltas reconcile across 393 empire snapshots and 1,836 reconstructed city snapshots. Dedicated recorder checks and all 44 backlog tests pass.
… save-stream markers

- Record configured/effective BBAI categories, shared supporting options, DLL-readable INI logging controls and finalized BUG/Autolog state once per new/load session. Share BBAI session sequences and supporting-option readers/formatting between both logs.
- Expose compiler and profiler/ReproTest build switches. At system-context level 3, sample debugger presence and selected IDE/build processes without interpreting process presence as active compilation.
- Share DLL/EXE binary-identity formatting, including actual numeric file/product resource versions when present. Use single runtime/display schemas with explicit unknown sentinels and preserve the existing collection gates.
- Centralize 29 existing gameplay/replay writer markers in SASSaveStreamFormat.h and report them alongside the actual loaded CvGame flag. Preserve marker values, encoded arithmetic and serialization layouts; loaded values and historical reader thresholds remain distinct from current writer constants.
- Observe Python logging state after lifecycle handlers finish, retain caller gates and cached gameplay checks, and use the Windows SDK's explicit wide-character process-enumeration APIs.
- Strengthen CI in both registry directions, add save-marker/lifecycle regression coverage, and document the diagnostic scope and named marker replacements.

Validation:
  - 55 focused tests and relevant source/document checks pass.
  - The binary-context contract rejects removal of either resource-version field or either shared consumer.
  - The amended C++ builds successfully as Debug-opt and completes new-game/load smoke tests: EXE resource versions are 3.1.9.0, missing DLL resources remain explicit, and runtime/display rows and loaded CvGame flags are correct.
  - Earlier save/load tests matched all 29 registry markers and BBAI/SASGameRecord session sequences.
  - System-context level-3 process enumeration remains untested at runtime.
…ularies; enrich performance context

- Generate the session settings row from one scalar name/value table while preserving existing getters, caches, clamping and field order. Include the previously omitted terrain-uppercase food-surplus threshold; keep validated palette strings in their specialized map legends.
- Enforce coverage of integer SAS_GAME_RECORD_* XML settings in CI, rejecting missing, duplicate and unknown recorder entries.
- At system-context level 3, record CPU brand/model and a new/load-time sample of process priority and affinity masks. Preserve explicit unavailable fields at lower levels and on query failure; add no per-turn polling.
- Generate building-focus enum bits and diagnostic descriptors from one local list, preserving all 17 bit values, labels and ordering. Keep the composite WORLDWONDER mask explicit.
- Generate the AI-strategy enum and existing shared descriptor table from one list too. Preserve all 18 bit values and raw names, the zero sentinel and consumer APIs; update CI to verify the list and both generators.
- Generate enums and existing label switches/indexed arrays from shared lists for 25 recorder reason/source/action vocabularies plus shared Found contexts, autoplay-end causes, war-declaration causes, tech-acquisition causes and research-target-change causes. Preserve numeric values, all 220 labels, special sentinels and fallback behavior; add no runtime registry or string-building work. Adapt the existing source checks to read the generated forms without adding feature assertions.

Scope decisions:
- Preserve existing getter APIs, XML-backed type names and semantic conversions such as grouping several UWAI reasons into one action. Shared lists consolidate fixed diagnostic vocabularies; native engine enums remain outside this refactor.
- Defer clean/incremental build provenance to build-time recording; runtime temp_files presence cannot establish how a binary was built.
- Add no arbitrary format-string length failure: intentional rows already exceed proposed caps, and physical source wrapping does not shorten emitted rows.
- Keep blocking checks focused on repository, XML/configuration, reference integrity, disabled logging defaults and explicit DLL-update intent; leave deeper source-shape, prose, balance and historical audits available for manual review.
- Reduce the SASGameRecord checker to disabled-by-default logging and public revision/history/output synchronization, removing retired implementation-shape checks and their dependent tests while retaining useful behavioral regressions.
- Keep missing/unused SAS-define and Long_Comments reference checks; ignore generated helper outputs when checking live Long_Comments references.
- Increment SASGameRecord to revision 147 for its checker changes and add the matching history entry. Preserve the existing downstream-update rule, including recorder-related checker and code-comment changes even when recorded semantics are unchanged.
- Update workflow/helper documentation and finalize revision 146's commit reference.
…revision 148)

- Match helper folders to separate repository, hygiene, documentation, XML, assets, diagnostics, runtime and source workflows, with descriptive named steps for each check.
- Restore all retained audits as blocking checks, including Markdown structure/prose, generated-document freshness, XML balance and naming rules, source provenance, strict XML lookups and custom-comment reflow; keep retired recorder implementation-shape checks removed.
- Split the backlog tests into descriptive modules and run the behavioral helper regression suite through its own blocking workflow; update imports and preserve inherited comment provenance when files move.
- Share Git range/text utilities through lib instead of importing the source checker into Markdown checks; remove redundant import-path setup and repeated branch resolution, and repair moved-helper documentation paths.
- Identify specialized Markdown lint, Python checks and AIP refresh by category while preserving their triggers and refresh behavior.
- Keep full commit metadata where history/range checks need it, using blob-filtered checkout to avoid eagerly downloading historical DLL and asset contents; add a real filtered-clone regression test for DLL-intent coverage.
- Update SASGameRecord revision 148 for its checker/history/test reorganization and restored automation, preserving recorder behavior and the existing revision policy.
- Reorganize the CI reference and contributor guidance around the subject folders, document automatic blocking coverage, repair navigation and focused-test commands, and remove the obsolete optional-audit README.
… support context

- Update DLL: install the current Release build.
- Embed pre-build request and artifact evidence in the DLL so installed binaries retain provenance without a separately copied runtime sidecar; distinguish embedded facts from current project/temp observations and size/FNV fingerprint matches.
- Add loaded D3D9 identity and active render, anti-aliasing, globe and movie settings to session diagnostics. Keep collection behind logging/context gates, with no per-turn hardware polling.
- Separate hardware identity, exact paths and process inspection into default-off supporting options, registered in the recorder settings report; richer context no longer implicitly exposes those details.
- Modernize Visual C++ 2010 Express and terminal builds with one current full AdvCiv.log/JSON pair beside each target DLL, covering Git context, start/end/result, duration, recognized warnings/errors, temporary artifacts and before/after DLL hashes.
- Require intentionally committed DLL updates to carry matching successful Release-family JSON evidence alongside the existing Update DLL intent marker; the current shipped DLL must retain valid JSON even on source-only commits. Keep full compiler logs local, with selected documentation examples, instead of requiring duplicate logs in Assets.
- Require rebuilt Release DLL evidence when added, removed or renamed C++-referenced define names anywhere under Assets/XML reach the repository default branch; report added/removed names separately. Exclude value/comment edits, moves between XML files and Python-only names; allow intermediate feature-branch source commits to share a later integration build.
- Document build completion and interruption checks, shipping evidence, privacy choices and current Release/Debug-opt examples; introduce copyright/purpose metadata identifying JSON reports as optional gameplay-independent support files. Centralize maintained examples under Docs/examples while retaining executable helpers in LLM_Helpers and preserving the processed AdvCiv 1.12 comparison reference.
- Keep external build reports outside runtime parsing; omit automatic timestamp archives, a separate reduced JSON format, wrapper-specific settings and shader-pack fingerprints.

Conceptual inspiration: graphics/support discussions highlighted missing build and runtime context; this adds general diagnostics without depending on a particular graphics add-on.
- GraphicsUpgrade: https://github.com/deliverator23/Civ4BTS-GraphicsUpgrade
- CivFanatics graphics discussion: https://forums.civfanatics.com/threads/graphicsupgrade-reflective-water-dynamic-shadows-day-night-cycle.705093/page-2 (and pages 1 and 3)
- Realism Invictus discussion: https://forums.civfanatics.com/threads/realism-invictus.411799/page-833 (and pages 832 and 834)
- Reddit discussion: https://www.reddit.com/r/CivIV/comments/1x3crys/an_incredible_new_mod_adds_real_sun_shadows/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant