18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-14 14:33:16 +01:00
Files
maszyna/tests/unit/test_ai_hints.cpp
jerrrrycho 8f51ea9a19 feat(ai): suggested pantograph setup for shunting in the .fiz (eu07/maszyna#461)
A new optional key in the AI section of the .fiz, ShuntPantstate= (bits as in
Pantstate: 1 front, 2 rear, 3 both), sets the pantographs the AI driver keeps
up while its order is Shunt or Loose_shunt, moving and standing alike: it
raises those of the setup and lowers the others once one of the setup
collects the voltage, and doesn't raise more when idling. Lowering on the
track's demand still comes first. Without the key (default 0) nothing
changes, so an ET41 no longer has to shunt on all four pantographs once its
.fiz says so.

SVN data, optional: add "AI: ShuntPantstate=<1|2|3>" to the .fiz of vehicles
that should shunt on fewer pantographs, e.g. dynamic/pkp/et41_v2/203e-a.fiz,
203e-b.fiz and their _dsa150 variants (no AI line there yet). Without it the
vehicles behave as before.

(eu07/maszyna#461)
2026-11-07 21:32:41 +01:00

32 lines
1.0 KiB
C++

#include "stdafx.h"
#include "doctest.h"
#include "vehicle.h"
using test::definition;
using test::vehicle;
// the hints for the AI driver from the AI section of the .fiz
TEST_CASE("ai hints: without the AI section the pantographs follow the built-in logic") {
vehicle wagon{definition::load("wagon")};
CHECK(wagon->AIHintPantstate == 0);
CHECK(wagon->AIHintShuntPantstate == 0);
CHECK(wagon->AIHintPantUpIfIdle);
}
TEST_CASE("ai hints: the suggested pantograph setup for shunting is read apart from the one for train mode") {
// eu07/maszyna#461: so the ET41 doesn't shunt with all of its four pantographs up
vehicle shunting{definition::load("wagon").set("AI", "Pantstate", 1).set("AI", "ShuntPantstate", 2)};
CHECK(shunting->AIHintPantstate == 1);
CHECK(shunting->AIHintShuntPantstate == 2);
}
TEST_CASE("ai hints: a .fiz with the setup for train mode only has none for shunting") {
vehicle train{definition::load("wagon").set("AI", "Pantstate", 3)};
CHECK(train->AIHintPantstate == 3);
CHECK(train->AIHintShuntPantstate == 0);
}