149 lines
6.2 KiB
GDScript
149 lines
6.2 KiB
GDScript
extends SceneTree
|
|
|
|
## M61-I03 / M61-I04 evidence: the campaign-wide pacing and the game-owned part
|
|
## of the decision interval. For sampled rounds of every region it runs the real
|
|
## battle (same ladder and Company as the balance sweep) and reports the seconds
|
|
## the game itself owns between decisions: the battle plus the settlement beat.
|
|
## Human reading and choice time sits on top, so this is a lower bound, and the
|
|
## report says so instead of claiming the full 105-165s band is met.
|
|
|
|
const ContentRegistry = preload("res://p10_0/content_registry.gd")
|
|
const ContractRun = preload("res://domain/contract_run.gd")
|
|
const Bridge = preload("res://entry/battle_sim_bridge.gd")
|
|
const Ladder = preload("res://domain/m80_ladder.gd")
|
|
|
|
const POST_BATTLE_SECONDS := 6.0
|
|
const DECISIONS_PER_BATTLE := 2
|
|
const INTERVAL_LOW := 105.0
|
|
const INTERVAL_HIGH := 165.0
|
|
|
|
var battles := 0
|
|
var timeouts := 0
|
|
var defeats := 0
|
|
var seconds_total := 0.0
|
|
var seconds_max := 0.0
|
|
var trivial_late := 0
|
|
var wall_late := 0
|
|
var remove_round10_extra := false
|
|
var remove_late_extras := false
|
|
var enemy_level_offset := 2
|
|
var enemy_region_cap := 0
|
|
var late_only := false
|
|
var region_from := 1
|
|
var region_to := 8
|
|
|
|
|
|
func _initialize() -> void:
|
|
call_deferred("_run")
|
|
|
|
|
|
func _run() -> void:
|
|
var args := OS.get_cmdline_user_args()
|
|
var attempts := int(args[0]) if args.size() > 0 else 2
|
|
var stride := int(args[1]) if args.size() > 1 else 3
|
|
remove_round10_extra = OS.get_environment("ABG_M61_REMOVE_ROUND10_EXTRA") == "1"
|
|
remove_late_extras = OS.get_environment("ABG_M61_REMOVE_LATE_EXTRAS") == "1"
|
|
late_only = OS.get_environment("ABG_M61_LATE_ONLY") == "1"
|
|
var region_from_text := OS.get_environment("ABG_M61_REGION_FROM")
|
|
if not region_from_text.is_empty():
|
|
region_from = clampi(int(region_from_text), 1, 8)
|
|
var region_to_text := OS.get_environment("ABG_M61_REGION_TO")
|
|
if not region_to_text.is_empty():
|
|
region_to = clampi(int(region_to_text), region_from, 8)
|
|
var offset_text := OS.get_environment("ABG_M61_ENEMY_LEVEL_OFFSET")
|
|
if not offset_text.is_empty():
|
|
enemy_level_offset = maxi(0, int(offset_text))
|
|
var region_cap_text := OS.get_environment("ABG_M61_ENEMY_REGION_CAP")
|
|
if not region_cap_text.is_empty():
|
|
enemy_region_cap = maxi(0, int(region_cap_text))
|
|
var catalog: Dictionary = ContentRegistry.snapshot()
|
|
var enemy_meta := Ladder.enemy_meta(catalog)
|
|
var item_pool := Ladder.item_pool(catalog)
|
|
print("region round party_size level clear_rate seconds per_decision")
|
|
for region_index in range(region_from, region_to + 1):
|
|
var enemy_ids := Ladder.enemy_ids(catalog, region_index)
|
|
if enemy_ids.is_empty():
|
|
continue
|
|
var late_clear := -1.0
|
|
var rounds: Array = []
|
|
if late_only:
|
|
rounds = [7, 10, 12]
|
|
else:
|
|
var round_index := 1
|
|
while round_index <= 12:
|
|
rounds.append(round_index)
|
|
round_index += stride
|
|
if not rounds.has(12):
|
|
rounds.append(12)
|
|
for sampled in rounds:
|
|
var level := Ladder.level(region_index, sampled)
|
|
var party_size := Ladder.capacity(sampled)
|
|
var recruits := Ladder.company(party_size, level, item_pool)
|
|
var formation: Array = []
|
|
for recruit in recruits:
|
|
formation.append(str(Dictionary(recruit).get("recruit_id", "")))
|
|
var clears := 0
|
|
var seconds_sum := 0.0
|
|
var carry := {}
|
|
for attempt in range(attempts):
|
|
var encounter := ContractRun.ordinary_encounter(region_index, enemy_ids, sampled, attempt, party_size)
|
|
if remove_late_extras:
|
|
encounter = _remove_one_ordinary(encounter, 2 if sampled >= 10 else 1 if sampled >= 7 else 0)
|
|
elif remove_round10_extra and sampled >= 10:
|
|
encounter = _remove_one_ordinary(encounter, 1)
|
|
var before := carry.duplicate(true)
|
|
var stat_region := region_index if enemy_region_cap <= 0 else mini(region_index, enemy_region_cap)
|
|
var result := Bridge.run_encounter("density|r%d|rnd%d|a%d" % [region_index, sampled, attempt],
|
|
formation, recruits, encounter, stat_region, Ladder.meta_at(enemy_meta, level + enemy_level_offset))
|
|
var seconds := float(result.get("ticks", 0)) / 10.0
|
|
seconds_sum += seconds
|
|
seconds_total += seconds
|
|
seconds_max = maxf(seconds_max, seconds)
|
|
if str(result.get("outcome", "")) == "timeout":
|
|
timeouts += 1
|
|
elif str(result.get("outcome", "")) != "victory":
|
|
defeats += 1
|
|
battles += 1
|
|
if str(result.get("outcome", "")) == "victory":
|
|
clears += 1
|
|
carry = ContractRun.carry_from(result)
|
|
else:
|
|
carry = before
|
|
var clear_rate := float(clears) / float(attempts)
|
|
var mean_seconds := seconds_sum / float(attempts)
|
|
var per_decision := (mean_seconds + POST_BATTLE_SECONDS) / float(DECISIONS_PER_BATTLE)
|
|
if int(sampled) == 12:
|
|
late_clear = clear_rate
|
|
print("%d %d %d %d %.2f %.1f %.1f" % [region_index, sampled, party_size, level,
|
|
clear_rate, mean_seconds, per_decision])
|
|
if late_clear >= 0.95:
|
|
trivial_late += 1
|
|
if late_clear >= 0.0 and late_clear <= 0.05:
|
|
wall_late += 1
|
|
var mean_all := seconds_total / float(maxi(1, battles))
|
|
var mean_decision := (mean_all + POST_BATTLE_SECONDS) / float(DECISIONS_PER_BATTLE)
|
|
var variant := "remove_late_extras" if remove_late_extras else "remove_round10_extra" if remove_round10_extra else "baseline"
|
|
if late_only:
|
|
variant = "%s_late_only" % variant
|
|
if enemy_level_offset != 2:
|
|
variant = "%s_level_offset_%d" % [variant, enemy_level_offset]
|
|
if enemy_region_cap > 0:
|
|
variant = "%s_region_cap_%d" % [variant, enemy_region_cap]
|
|
print("ABG_M61_CAMPAIGN_DENSITY_OK variant=%s regions=%d-%d rounds=%s battles=%d timeouts=%d defeats=%d battle_mean=%.1fs battle_max=%.1fs per_decision_mean=%.1fs per_decision_max=%.1fs trivial_late=%d wall_late=%d band=%.0f-%.0f human_share=on_top"
|
|
% [variant, region_from, region_to, "7,10,12" if late_only else "sampled", battles, timeouts, defeats, mean_all, seconds_max, mean_decision,
|
|
(seconds_max + POST_BATTLE_SECONDS) / float(DECISIONS_PER_BATTLE),
|
|
trivial_late, wall_late, INTERVAL_LOW, INTERVAL_HIGH])
|
|
quit(0)
|
|
|
|
|
|
func _remove_one_ordinary(encounter: Array, count: int) -> Array[Dictionary]:
|
|
var trimmed: Array[Dictionary] = []
|
|
for value in encounter:
|
|
trimmed.append(Dictionary(value).duplicate(true))
|
|
for _step in range(count):
|
|
for index in range(trimmed.size() - 1, -1, -1):
|
|
if String(Dictionary(trimmed[index]).get("class", "ordinary")) == "ordinary":
|
|
trimmed.remove_at(index)
|
|
break
|
|
return trimmed
|