H02 StampTreatyTurns -- the diplomacy ledger's "this treaty was last in force on turn N" stamp, over every ordered pair of players that holds one, creating the entry on demand. It is a host step, not a phase of either turn driver: its sole caller is the command-application step, which runs after the frame counter has advanced and before both drivers. On a turn with no combat and no diplomatic command it is the only writer of these fields, which is why a whole per-player dipstats vector is its output. Read from the instruction stream; three things an earlier reading had wrong are corrected in findings/subsystems/treaty-turn-stamp.md: the stamped value is the TURN and not the modification counter, the relation codes are 3=allied / 2=NAP / 1=cease-fire and not the reverse, and the bit is the player's index field rather than its position in the player vector -- the opposite convention from the shared-vision mask two files away. Measured, closed and regressed reported separately and never netted: turn1 -> turn2 (reference) 209 -> 132 closed 77 (was 51), regressed 0 turn2 -> turn3 108 -> 73 closed 35 (was 21), regressed 0 human-turn2 -> turn3 closed 76 (was 64), regressed 0 zuul-turn15 -> turn16 closed 30 (was 18), regressed 0 zuul-turn16 -> turn17 closed 29 (was 17), regressed 0 The last three are pairs from a different game at turns 2, 15 and 16 that the model was never fitted to, and it closes exactly the twelve ordered treaty pairs each of them holds. The rule also reproduces the ledger of ten of the eleven corpus saves entry for entry, including each entry's order and every stamped value; the eleventh is the turn-1 save whose ledger no turn has yet written, and it is the reference pair's input. app_test_treaty pins the five things the corpus cannot separate: the relation codes (no save exercises cease-fire), the bit's source, the missing alliance-id guard, the -1 initialiser on a fresh entry, and the append-at-the-end order that makes re-running the step idempotent instead of duplicating rows. The betrayal half of the same function needs the turn's diplomatic commands; with no command stream it is provably a no-op and is not modelled.
41 lines
2 KiB
CMake
41 lines
2 KiB
CMake
# Standalone turn-driver tests.
|
|
#
|
|
# test_catalog needs nothing but the catalog and always runs.
|
|
# test_turn reads the owner's saves via SOTS_SAVES_DIR at run time and skips cleanly when it
|
|
# is unset -- no .sav ever enters this repo.
|
|
add_executable(app_test_catalog test_catalog.cpp)
|
|
target_link_libraries(app_test_catalog PRIVATE sots_app)
|
|
add_test(NAME app_catalog COMMAND app_test_catalog)
|
|
|
|
add_executable(app_test_turn test_turn.cpp)
|
|
target_link_libraries(app_test_turn PRIVATE sots_app)
|
|
add_test(NAME app_turn COMMAND app_test_turn)
|
|
|
|
# The trade-raid word count is pinned against a scripted generator, so it always runs.
|
|
add_executable(app_test_trade_raid test_trade_raid.cpp)
|
|
target_link_libraries(app_test_trade_raid PRIVATE sots_app)
|
|
add_test(NAME app_trade_raid COMMAND app_test_trade_raid)
|
|
|
|
# The alliance mask, as a rule. Pins the three things the corpus cannot separate -- the bit
|
|
# index, the OR, and the guard -- so it always runs.
|
|
add_executable(app_test_alliance test_alliance.cpp)
|
|
target_link_libraries(app_test_alliance PRIVATE sots_app)
|
|
add_test(NAME app_alliance COMMAND app_test_alliance)
|
|
|
|
# The treaty-turn stamp, as a rule. Pins the five things the corpus cannot separate -- the
|
|
# relation codes, the bit's source, the missing alliance-id guard, the -1 initialiser and the
|
|
# append order -- so it always runs.
|
|
add_executable(app_test_treaty test_treaty.cpp)
|
|
target_link_libraries(app_test_treaty PRIVATE sots_app)
|
|
add_test(NAME app_treaty COMMAND app_test_treaty)
|
|
|
|
# The turn-record model against the record the game itself archived; needs the owner's saves.
|
|
add_executable(app_test_turn_record test_turn_record.cpp)
|
|
target_link_libraries(app_test_turn_record PRIVATE sots_app)
|
|
add_test(NAME app_turn_record COMMAND app_test_turn_record)
|
|
|
|
foreach(_t app_test_catalog app_test_turn app_test_trade_raid app_test_alliance
|
|
app_test_treaty app_test_turn_record)
|
|
target_include_directories(${_t} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
|
target_compile_options(${_t} PRIVATE -Wall -Wextra -Wpedantic)
|
|
endforeach()
|