## Plays bot-only duos matches (M7) on a run of seeds: 12 teams of two bots. Checks ## every match ends with one winning team, bots went down and revived teammates, no hit ## between teammates did damage, and the ticks kept within budget. ## ## tools/godot.sh --script res://tools/duo_matches.gd -- [--seeds=10] [--first=1] ## ## Prints one JSON line per match and a summary. Exits 1 if a check fails. extends SceneTree func _init() -> void: var count: int = 10 var first: int = 1 for arg: String in OS.get_cmdline_user_args(): if arg.begins_with("--seeds="): count = arg.trim_prefix("--seeds=").to_int() elif arg.begins_with("--first="): first = arg.trim_prefix("--first=").to_int() var results: Array[Dictionary] = [] var downs: int = 0 var revives: int = 0 var team_hits: int = 0 var one_team: int = 0 for seed_value: int in range(first, first + count): var result: Dictionary = BotBatch.run_match(seed_value, Tuning.SOLO_PLAYERS, -1, false, Tuning.DUO_TEAM_SIZE) result.erase("building") results.append(result) downs += int(result["downs"]) revives += int(result["revives"]) team_hits += int(result["team_hits"]) one_team += 1 if int(result["winner_teams"]) == 1 else 0 print(JSON.stringify({"seed": seed_value, "finished": result["finished"], "ticks": result["ticks"], "winner_teams": result["winner_teams"], "downs": result["downs"], "revives": result["revives"], "team_hits": result["team_hits"], "causes": result["causes"], "p99_us": result["timing"].get("p99_us", 0)})) var total: Dictionary = BotBatch.summarise(results) var problems: Array[String] = [] if total["finished"] != count or one_team != count: problems.append("%d of %d matches finished with one winning team" % [one_team, count]) if downs == 0 or revives == 0: problems.append("bots went down %d times and revived %d times; both should happen" % [downs, revives]) if team_hits > 0: problems.append("%d hits between teammates did damage" % team_hits) if int(total["worst_p99_us"]) > ServerLoop.TICK_BUDGET_USEC: problems.append("the worst match's p99 tick was %d us, over the %d us budget" % [total["worst_p99_us"], ServerLoop.TICK_BUDGET_USEC]) for problem: String in problems: print("duo-matches FAIL: %s" % problem) if problems.is_empty(): print("duo-matches: ok (%d matches, each won by one team, %d downs, %d revives, %.1f%% drowned, worst p99 %d us)" % [count, downs, revives, total["drown_share"] * 100.0, total["worst_p99_us"]]) quit(0 if problems.is_empty() else 1)