mirror of
https://github.com/db9979/uconsole_asw_game.git
synced 2026-12-05 12:24:25 +01:00
Crew assist: a warship's TMA solution needs a better fit before a shot
tools/fairness.py --crewed over 20 seeds of s1, s5, s7 and s17: taking every solution from the range threshold on made the frigate lose the duel in all 20 games, because a warship manoeuvres while it hunts and a weak solution on it collapses the range. A warship's solution now needs 0.5, a merchant keeps the range threshold. Over the four scenarios the balance moves from 57:23 to 45:35 (frigate:boat) and the boat fires in 34 of 80 games instead of none. Numbers and data files: /mnt/project-files/balance/paket-7-2026-10-06/. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
6 files changed
+41
-12
No files matched your search
@@ -32,7 +32,7 @@ Die Statuszeile unten zeigt das neueste Ereignis und die wichtigste Telemetrie;
|
||||
- **U-Boot-Kommando:** weicht einem gehörten Torpedo oder Ping aus, folgt sonst dem Abschnitt der U-Boot-Mission oder läuft in einer Fregattenmission eine Fregatte an, die das eigene Sonar innerhalb von 12 sm geortet hat, und patrouilliert sonst mit 4 kn unter der Sprungschicht um den Startpunkt. Fällt die Batterie unter 35 % und jagt niemand das U-Boot, geht es auf Schnorcheltiefe.
|
||||
- **U-Boot-Waffen:** hält die Rohre geladen, flutet leise, sobald ein gehörtes Ziel eine Ortung innerhalb von 8 sm hat, und schießt einen Torpedo nach dem anderen auf eine Ortung innerhalb von 4 sm. Ziel ist ein Kontakt, dessen Signatur die Bibliothek nur von Kriegsschiffen kennt (beim Geleitzugangriff von Handelsschiffen).
|
||||
- **Maschinenraum:** schnorchelt ungejagt bis 95 % Ladung, hält den Trimm automatisch, beantwortet schlechte Luft mit Absorbern und Sauerstoffkerzen und schickt die zwei Leckteams dorthin, wo Feuer, Lecks oder Wasser am schlimmsten sind.
|
||||
- **Sonar und Mast:** Das Sonar hält den Fokus auf dem lautesten frischen Kontakt; der Mast fährt bei einem solchen Alarm ein. Navigation und Funkraum halten nur Wache.
|
||||
- **Sonar und Mast:** Das Sonar hält den Fokus auf dem Ziel, auf das die Waffen schießen würden (sonst, wenn nur Browser das U-Boot führen, auf dem lautesten frischen Kontakt), und übernimmt die automatische TMA-Lösung darauf als Ortung, sobald ihre Güte 35 % erreicht (50 % bei einem Kriegsschiff, das bei der Jagd manövriert), erneut alle 30 s, solange keine Ping- oder Sehrohrortung besteht, wie ein Bediener mit `K`; mit dieser Ortung schießen die Waffen. Auf der uConsole fokussiert es nur Ziele, ein dort mit `Auf`/`Ab` gewählter Kontakt bleibt also gewählt, außer er ist ein verstummtes Ziel. Der Mast fährt bei einem solchen Alarm ein. Navigation und Funkraum halten nur Wache.
|
||||
- **Der Befehl eines Spielers gilt:** Eine Station, die die KI besetzt, übersteuert nie, was ein Spieler an einer anderen Station befiehlt. Mit einem Spieler an der Navigation lässt die KI-Führung Kurs, Tiefe und Ausweichen in Ruhe, mit einem im Maschinenraum Fahrt und Schleichfahrt; mit einem an der Führung lässt der KI-Maschinenraum Trimm und Leckteams in Ruhe, und die KI-Maststation lässt einen an der Führung oder im Funkraum ausgefahrenen Mast auch bei Alarm oben. Solange ein Spieler an Mast oder Funkraum den Mast oben hält, hält die KI-Führung das U-Boot auf Sehrohrtiefe; erst mit eingefahrenem Mast taucht es wieder. Auf der Fregatte steuert die KI-Brücke nicht, solange ein Spieler im Maschinenraum sitzt, und KI-Waffen und Seefernaufklärer bestimmen kein neues Ziel über ein aktuelles Ziel, das ein Spieler an Sonar, OPZ oder Waffen gewählt hat. Ein am uConsole mit `Auf`/`Ab` gewählter Kontakt bleibt gewählt.
|
||||
|
||||
## Wetter- & Sonar-Analyse (Taste 0) {#ref-weather-station}
|
||||
|
||||
@@ -32,7 +32,7 @@ The bottom status ticker shows the newest event and key telemetry; `F11` opens t
|
||||
- **Submarine command:** evades a torpedo or a ping it has heard, otherwise follows the submarine mission's leg or, in a frigate mission, closes a frigate the submarine's own sonar has fixed within 12 NM and else patrols at 4 kn below the layer around its start point. It comes to snorkel depth when the battery falls below 35 % and nothing hunts the submarine.
|
||||
- **Submarine weapons:** keeps the tubes loaded, floods quietly once a heard target has a fix within 8 NM and fires one torpedo at a time down a fix within 4 NM. A target is a contact whose signature the library knows only from warships (in the convoy attack, from merchants).
|
||||
- **Engine room:** snorkels to charge up to 95 % while unhunted, keeps the trim automatic, answers foul air with absorbers and oxygen candles and sends the two damage-control teams where fire, leaks or water are worst.
|
||||
- **Sonar and mast:** the sonar keeps the focus on the loudest fresh contact; the mast comes down on such an alarm. Navigation and the radio room only keep watch.
|
||||
- **Sonar and mast:** the sonar keeps the focus on the target the weapons would fire at (else, with the submarine in browser hands only, on the loudest fresh contact) and accepts the automatic TMA solution on it as its fix once the solution's quality reaches 35 % (50 % on a warship, which manoeuvres while it hunts), again every 30 s while no ping or periscope fix is held, as an operator does with `K`; that fix lets the weapons fire. On the uConsole it focuses targets only, so a contact picked there with `Up`/`Down` stays picked unless it is a target that fell silent. The mast comes down on such an alarm. Navigation and the radio room only keep watch.
|
||||
- **A player's order wins:** a station the AI mans never overrides what a player at another station commands. With a player at Navigation the AI command leaves course, depth and evasion alone; with one in the engine room it leaves speed and silent running; with one at command the AI engine room leaves the trim and the damage-control teams, and the AI mast station leaves a mast raised at command or in the radio room up even on an alarm. While a player at the mast or in the radio room holds the mast up, the AI command keeps the submarine at periscope depth; it dives again once the mast is down. On the frigate the AI Bridge does not steer while a player is in the engine room, and the AI weapons and patrol aircraft do not re-designate a current target a player chose at Sonar, OPZ or Weapons. A contact picked on the uConsole with `Up`/`Down` stays picked.
|
||||
|
||||
## Weather & sonar analysis (key 0) {#ref-weather-station}
|
||||
|
||||
@@ -2419,7 +2419,7 @@ Die Statuszeile unten zeigt das neueste Ereignis und die wichtigste Telemetrie;
|
||||
- **U-Boot-Kommando:** weicht einem gehörten Torpedo oder Ping aus, folgt sonst dem Abschnitt der U-Boot-Mission oder läuft in einer Fregattenmission eine Fregatte an, die das eigene Sonar innerhalb von 12 sm geortet hat, und patrouilliert sonst mit 4 kn unter der Sprungschicht um den Startpunkt. Fällt die Batterie unter 35 % und jagt niemand das U-Boot, geht es auf Schnorcheltiefe.
|
||||
- **U-Boot-Waffen:** hält die Rohre geladen, flutet leise, sobald ein gehörtes Ziel eine Ortung innerhalb von 8 sm hat, und schießt einen Torpedo nach dem anderen auf eine Ortung innerhalb von 4 sm. Ziel ist ein Kontakt, dessen Signatur die Bibliothek nur von Kriegsschiffen kennt (beim Geleitzugangriff von Handelsschiffen).
|
||||
- **Maschinenraum:** schnorchelt ungejagt bis 95 % Ladung, hält den Trimm automatisch, beantwortet schlechte Luft mit Absorbern und Sauerstoffkerzen und schickt die zwei Leckteams dorthin, wo Feuer, Lecks oder Wasser am schlimmsten sind.
|
||||
- **Sonar und Mast:** Das Sonar hält den Fokus auf dem lautesten frischen Kontakt; der Mast fährt bei einem solchen Alarm ein. Navigation und Funkraum halten nur Wache.
|
||||
- **Sonar und Mast:** Das Sonar hält den Fokus auf dem Ziel, auf das die Waffen schießen würden (sonst, wenn nur Browser das U-Boot führen, auf dem lautesten frischen Kontakt), und übernimmt die automatische TMA-Lösung darauf als Ortung, sobald ihre Güte 35 % erreicht (50 % bei einem Kriegsschiff, das bei der Jagd manövriert), erneut alle 30 s, solange keine Ping- oder Sehrohrortung besteht, wie ein Bediener mit `K`; mit dieser Ortung schießen die Waffen. Auf der uConsole fokussiert es nur Ziele, ein dort mit `Auf`/`Ab` gewählter Kontakt bleibt also gewählt, außer er ist ein verstummtes Ziel. Der Mast fährt bei einem solchen Alarm ein. Navigation und Funkraum halten nur Wache.
|
||||
- **Der Befehl eines Spielers gilt:** Eine Station, die die KI besetzt, übersteuert nie, was ein Spieler an einer anderen Station befiehlt. Mit einem Spieler an der Navigation lässt die KI-Führung Kurs, Tiefe und Ausweichen in Ruhe, mit einem im Maschinenraum Fahrt und Schleichfahrt; mit einem an der Führung lässt der KI-Maschinenraum Trimm und Leckteams in Ruhe, und die KI-Maststation lässt einen an der Führung oder im Funkraum ausgefahrenen Mast auch bei Alarm oben. Solange ein Spieler an Mast oder Funkraum den Mast oben hält, hält die KI-Führung das U-Boot auf Sehrohrtiefe; erst mit eingefahrenem Mast taucht es wieder. Auf der Fregatte steuert die KI-Brücke nicht, solange ein Spieler im Maschinenraum sitzt, und KI-Waffen und Seefernaufklärer bestimmen kein neues Ziel über ein aktuelles Ziel, das ein Spieler an Sonar, OPZ oder Waffen gewählt hat. Ein am uConsole mit `Auf`/`Ab` gewählter Kontakt bleibt gewählt.
|
||||
|
||||
### Wetter- & Sonar-Analyse (Taste 0)
|
||||
|
||||
@@ -2418,7 +2418,7 @@ The bottom status ticker shows the newest event and key telemetry; `F11` opens t
|
||||
- **Submarine command:** evades a torpedo or a ping it has heard, otherwise follows the submarine mission's leg or, in a frigate mission, closes a frigate the submarine's own sonar has fixed within 12 NM and else patrols at 4 kn below the layer around its start point. It comes to snorkel depth when the battery falls below 35 % and nothing hunts the submarine.
|
||||
- **Submarine weapons:** keeps the tubes loaded, floods quietly once a heard target has a fix within 8 NM and fires one torpedo at a time down a fix within 4 NM. A target is a contact whose signature the library knows only from warships (in the convoy attack, from merchants).
|
||||
- **Engine room:** snorkels to charge up to 95 % while unhunted, keeps the trim automatic, answers foul air with absorbers and oxygen candles and sends the two damage-control teams where fire, leaks or water are worst.
|
||||
- **Sonar and mast:** the sonar keeps the focus on the loudest fresh contact; the mast comes down on such an alarm. Navigation and the radio room only keep watch.
|
||||
- **Sonar and mast:** the sonar keeps the focus on the target the weapons would fire at (else, with the submarine in browser hands only, on the loudest fresh contact) and accepts the automatic TMA solution on it as its fix once the solution's quality reaches 35 % (50 % on a warship, which manoeuvres while it hunts), again every 30 s while no ping or periscope fix is held, as an operator does with `K`; that fix lets the weapons fire. On the uConsole it focuses targets only, so a contact picked there with `Up`/`Down` stays picked unless it is a target that fell silent. The mast comes down on such an alarm. Navigation and the radio room only keep watch.
|
||||
- **A player's order wins:** a station the AI mans never overrides what a player at another station commands. With a player at Navigation the AI command leaves course, depth and evasion alone; with one in the engine room it leaves speed and silent running; with one at command the AI engine room leaves the trim and the damage-control teams, and the AI mast station leaves a mast raised at command or in the radio room up even on an alarm. While a player at the mast or in the radio room holds the mast up, the AI command keeps the submarine at periscope depth; it dives again once the mast is down. On the frigate the AI Bridge does not steer while a player is in the engine room, and the AI weapons and patrol aircraft do not re-designate a current target a player chose at Sonar, OPZ or Weapons. A contact picked on the uConsole with `Up`/`Down` stays picked.
|
||||
|
||||
### Weather & sonar analysis (key 0)
|
||||
|
||||
@@ -22,7 +22,8 @@ one the uConsole shows while it plays the boat, is left alone.
|
||||
contact), so the sonar room runs its TMA on it; a contact picked on the
|
||||
uConsole stays picked unless it is a target that fell silent,
|
||||
and accept the automatic TMA solution on that target as its fix once it
|
||||
is good enough (``ACCEPT_MIN_QUALITY``, again every ``ACCEPT_EVERY_S``),
|
||||
is good enough (``ACCEPT_MIN_QUALITY``, a warship ``ACCEPT_WARSHIP_QUALITY``,
|
||||
again every ``ACCEPT_EVERY_S``),
|
||||
as an operator does with K: the fix lets the weapons fire.
|
||||
- Mast/ESM: lower the mast when an alarm comes in.
|
||||
- Navigation and radio room: watch only.
|
||||
@@ -59,8 +60,11 @@ PATROL_LEG_S = 900.0
|
||||
FIX_MAX_AGE_S = 120.0
|
||||
EVADE_AGAIN_S = 60.0
|
||||
# The sonar room accepts the automatic TMA solution on a target this good,
|
||||
# and renews the fix this often while it holds no ping or visual fix.
|
||||
# and renews the fix this often while it holds no ping or visual fix. A
|
||||
# warship manoeuvres while it hunts, so a weaker solution on it collapses
|
||||
# the range and wastes the shot: it needs a better one (tools/fairness.py).
|
||||
ACCEPT_MIN_QUALITY = config.TMA_RANGE_MIN_QUALITY
|
||||
ACCEPT_WARSHIP_QUALITY = 0.5
|
||||
ACCEPT_EVERY_S = 30.0
|
||||
ROLES = ("uboot", "uboot_sonar", "uboot_weapons", "uboot_engine", "uboot_esm",
|
||||
"uboot_nav", "uboot_radio")
|
||||
@@ -105,17 +109,25 @@ def _fresh(game, contact, age_s=FIX_MAX_AGE_S) -> bool:
|
||||
return 0.0 <= game.sim_t - contact.last_seen <= age_s
|
||||
|
||||
|
||||
def targets(game, boat) -> list:
|
||||
"""Fresh contacts the crew would shoot at, nearest known fix first."""
|
||||
WARSHIPS = frozenset({"KAMPFSCHIFF"})
|
||||
|
||||
|
||||
def _target_categories(game) -> frozenset:
|
||||
"""The ship categories the crew shoots at in this mission."""
|
||||
kind = boat_missions.mode(game)
|
||||
if kind == "free_boat":
|
||||
# A free patrol attacks merchants only on HQ's order to sink one.
|
||||
from src.core import free_roam
|
||||
order = free_roam.active_order(game)
|
||||
kind = "convoy_attack" if order is not None and order["kind"] == "attack" else None
|
||||
categories = (frozenset({"TANKER", "FRACHT", "PASSAGIER"}) if kind == "convoy_attack"
|
||||
else frozenset({"TANKER"}) if kind in ("escort", "ras")
|
||||
else frozenset({"KAMPFSCHIFF"}))
|
||||
return (frozenset({"TANKER", "FRACHT", "PASSAGIER"}) if kind == "convoy_attack"
|
||||
else frozenset({"TANKER"}) if kind in ("escort", "ras")
|
||||
else WARSHIPS)
|
||||
|
||||
|
||||
def targets(game, boat) -> list:
|
||||
"""Fresh contacts the crew would shoot at, nearest known fix first."""
|
||||
categories = _target_categories(game)
|
||||
phrases = _signatures(game.runtime_catalog, categories)
|
||||
rows = [contact for contact in boat.station.sonar.contacts.values()
|
||||
if _fresh(game, contact, 10.0)
|
||||
@@ -288,7 +300,9 @@ def _accept_solution(game, boat, contact) -> bool:
|
||||
if contact.tma_seen is not None and 0.0 <= game.sim_t - contact.tma_seen < ACCEPT_EVERY_S:
|
||||
return False
|
||||
solution = boat.station.sonar.tma_proposals.get(contact.target_id)
|
||||
if solution is None or solution.quality < ACCEPT_MIN_QUALITY:
|
||||
least = (ACCEPT_WARSHIP_QUALITY if _target_categories(game) == WARSHIPS
|
||||
else ACCEPT_MIN_QUALITY)
|
||||
if solution is None or solution.quality < least:
|
||||
return False
|
||||
contact.accept_operator_tma(solution.pos, solution.course, solution.speed,
|
||||
solution.quality, game.sim_t)
|
||||
|
||||
@@ -278,3 +278,18 @@ def test_the_ai_sonar_takes_a_good_tma_solution_on_a_target_as_its_fix(monkeypat
|
||||
assert boat_autocrew.sonar(game, boat) == "monitoring" and len(taken) == 1
|
||||
target.tma_seen, target.range_source = None, "ping"
|
||||
assert boat_autocrew.sonar(game, boat) == "monitoring" and len(taken) == 1
|
||||
|
||||
|
||||
def test_a_warship_needs_a_better_tma_solution_than_a_merchant(monkeypatch):
|
||||
from types import SimpleNamespace
|
||||
game, boat = _assisted_boat("uboot_weapons")
|
||||
taken = []
|
||||
contact = SimpleNamespace(target_id=-905, range_source=None, tma_seen=None,
|
||||
accept_operator_tma=lambda *args: taken.append(args))
|
||||
middling = (boat_autocrew.ACCEPT_MIN_QUALITY + boat_autocrew.ACCEPT_WARSHIP_QUALITY) / 2
|
||||
boat.station.sonar.tma_proposals[contact.target_id] = SimpleNamespace(
|
||||
pos=(0.0, 0.0), course=0.0, speed=5.0, quality=middling)
|
||||
monkeypatch.setattr(boat_autocrew, "_target_categories", lambda game: boat_autocrew.WARSHIPS)
|
||||
assert not boat_autocrew._accept_solution(game, boat, contact) and not taken
|
||||
monkeypatch.setattr(boat_autocrew, "_target_categories", lambda game: frozenset({"FRACHT"}))
|
||||
assert boat_autocrew._accept_solution(game, boat, contact) and len(taken) == 1
|
||||
Reference in new issue
Block a user