M5: Bot looting, combat and tide awareness
BotBrain plays a match with the commands a player sends: it picks a landing marker near the barge's route, loots points of interest (following their own walking routes into huts, lofts and piers), fights opponents it can see, bandages itself, and gets to ground the coming tide will leave dry. BotWorld is the map every bot shares: loot markers, routes, and each tide phase's safe ground, which is the dry land joined to the island's highest walkable ground. Three difficulties (Tuning.BOT_DIFFICULTIES) set reaction time, sight range and aim error. The server mixes them unless --bot-difficulty says otherwise. NavGrid labels connected regions when it is built, so a goal that is cut off is turned down without a search of the whole island (about 70 ms each). make bot-matches plays 20 bot-only matches and checks winners, drownings and difficulty. Seeds 101 to 120: 20 of 20 with a winner, 7 of 460 deaths were drownings (1.5%), easy bots placed worst (13.7 against 11.8 and 12.0) and hard bots took the most eliminations (186 against 137 and 132). Closes #28 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
## Plays bot-only matches on a run of seeds and checks issue M5's acceptance: every
|
||||
## match ends with a winner, under a tenth of deaths are drownings, and difficulty
|
||||
## shows: easy bots place worst and hard bots take the most eliminations.
|
||||
##
|
||||
## tools/godot.sh --script res://tools/bot_matches.gd -- [--seeds=20] [--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 = 20
|
||||
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] = []
|
||||
for seed_value: int in range(first, first + count):
|
||||
var result: Dictionary = BotBatch.run_match(seed_value)
|
||||
results.append(result)
|
||||
print(JSON.stringify(result))
|
||||
var total: Dictionary = BotBatch.summarise(results)
|
||||
print(JSON.stringify({"summary": total}))
|
||||
var problems: Array[String] = []
|
||||
if total["with_winner"] != count or total["finished"] != count:
|
||||
problems.append("%d of %d matches finished with a winner" % [total["with_winner"], count])
|
||||
if total["drown_share"] >= 0.1:
|
||||
problems.append("%.1f%% of deaths were drownings" % (total["drown_share"] * 100.0))
|
||||
# Placement is noisy between neighbouring levels over 20 matches, so the check is on
|
||||
# what holds up: easy bots place worst, and hard bots take the most eliminations.
|
||||
var mean: Dictionary = total["mean_place"]
|
||||
var kills: Dictionary = total["eliminations"]
|
||||
if not (mean.get("easy", 0.0) > mean.get("normal", 99.0) and mean.get("easy", 0.0) > mean.get("hard", 99.0)):
|
||||
problems.append("easy bots didn't place worst: %s" % mean)
|
||||
if not (kills.get("hard", 0) > kills.get("normal", 0) and kills.get("hard", 0) > kills.get("easy", 0)):
|
||||
problems.append("hard bots didn't take the most eliminations: %s" % kills)
|
||||
for problem: String in problems:
|
||||
print("bot-matches FAIL: %s" % problem)
|
||||
if problems.is_empty():
|
||||
print("bot-matches: ok (%d matches, all with a winner, %.1f%% drowned, mean place %s, eliminations %s)" % [count, total["drown_share"] * 100.0, mean, kills])
|
||||
quit(0 if problems.is_empty() else 1)
|
||||
@@ -0,0 +1 @@
|
||||
uid://dgpnwi76yahi5
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
# Plays bot-only matches on a run of seeds, under nice, and prints one JSON line per
|
||||
# match, a summary and the verdict. See tools/bot_matches.gd for what is checked.
|
||||
#
|
||||
# tools/bot_matches.sh seeds 1 to 20
|
||||
# BOT_MATCH_SEEDS=5 BOT_MATCH_FIRST=40 tools/bot_matches.sh
|
||||
set -uo pipefail
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
||||
|
||||
count="${BOT_MATCH_SEEDS:-20}"
|
||||
first="${BOT_MATCH_FIRST:-1}"
|
||||
raw="$(nice -n 15 tools/godot.sh --script res://tools/bot_matches.gd -- --seeds="$count" --first="$first" 2>&1)"
|
||||
code=$?
|
||||
grep -E '^\{|^bot-matches' <<<"$raw"
|
||||
if [[ "$code" -ne 0 ]] && ! grep -q '^bot-matches' <<<"$raw"; then
|
||||
echo "bot-matches FAIL: the run exited $code"
|
||||
tail -n 15 <<<"$raw"
|
||||
fi
|
||||
exit "$code"
|
||||
Reference in New Issue
Block a user