Give the six play settings of the tactics board an effect; draw the board in chalk

- Match engine (Modern turn driver only, MatchEngine::tactic_effects): wing play,
  through balls, goal kicks, flat or high balls, offside trap and pressing of a human
  side shift how often it and its opponent come to a chance (play_shift, at most two
  steps of the chance roll). Each setting pays in one situation and costs in another;
  pressing also raises the foul roll. No random numbers are drawn; computer sides and
  the Classic core are unchanged. Documented in docs/DIFFERENCES.md.
- The tactics read names the settings; desk and live dialog show every value in words
  with one sentence on its effect. The live dialog offers all eight settings again.
- The tactics board is a slate with a wooden frame, drawn in wobbling chalk strokes.
- modern_season_sim: SIM_TACTICS keeps a tactic set for measuring; new
  modern_play_shift_tests pin the direction of every setting.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
MichaelandClaude Fable 5.2 committed 2026-11-14 14:49:19 +01:00
1 parent 9708b720b2
commit 919342a5ae
16 files changed
+344 -80

No files matched your search

+81
View File
@@ -0,0 +1,81 @@
// SPDX-License-Identifier: GPL-3.0-only
// Dreierpack's play settings (tactics board items 1-6): each one pays in one situation and
// costs in another, and a computer side (no board) is never touched.
#include "game/match_engine.hpp"
#include <array>
#include <cstdio>
#include <stdexcept>
#include <string>
namespace {
void require(bool yes, const std::string& message) {
if (!yes) throw std::runtime_error(message);
}
// a side record: byte 2 the strength, byte 6 the balance (above 100: more condition than technique)
std::array<uint8_t, 9> side(int strength, int balance) {
std::array<uint8_t, 9> r{};
r[2] = uint8_t(strength), r[6] = uint8_t(balance);
return r;
}
// a board with one setting; flat balls on a dry pitch for a technique side count +1 by themselves
std::array<uint8_t, 8> board(int item, int value) {
std::array<uint8_t, 8> b{};
if (item >= 0) b[size_t(item)] = uint8_t(value);
return b;
}
} // namespace
int main() {
using bmh::play_shift;
try {
const auto even = side(70, 100), strong = side(80, 100), weak = side(60, 100), runners = side(70, 130);
const auto none = board(-1, 0);
// no boards: nothing changes
require(play_shift(even.data(), even.data(), nullptr, nullptr, 1, 2, 30, false) == 0, "computer sides are untouched");
const int base = play_shift(even.data(), even.data(), none.data(), nullptr, 1, 1, 30, false);
require(base == 1, "flat play suits a technique side on a dry pitch");
require(play_shift(even.data(), even.data(), none.data(), nullptr, 1, 1, 30, true) == -2, "flat play suffers on a wet pitch");
const auto high = board(4, 1);
require(play_shift(even.data(), even.data(), high.data(), nullptr, 1, 1, 30, true) == 1, "high balls suit a wet pitch");
require(play_shift(runners.data(), even.data(), high.data(), nullptr, 1, 1, 30, false) == 1, "high balls suit a condition side");
require(play_shift(even.data(), even.data(), high.data(), nullptr, 1, 1, 30, false) == -1, "high balls cost a technique side");
const auto wings = board(1, 3);
require(play_shift(strong.data(), weak.data(), wings.data(), nullptr, 1, 1, 30, false) > base, "wing play pays for the stronger side");
require(play_shift(weak.data(), strong.data(), wings.data(), nullptr, 1, 1, 30, false) < base, "wing play costs the weaker side");
const auto through = board(2, 3);
require(play_shift(even.data(), even.data(), through.data(), nullptr, 1, 3, 30, false) > base, "through balls pay against an attacking side");
require(play_shift(even.data(), even.data(), through.data(), nullptr, 1, 0, 30, false) < base, "through balls fail against a deep side");
const auto kicks = board(3, 3);
require(play_shift(even.data(), even.data(), kicks.data(), nullptr, 0, 1, 30, false) > base, "long goal kicks pay for a defensive side");
require(play_shift(even.data(), even.data(), kicks.data(), nullptr, 3, 1, 30, false) < base, "long goal kicks cost an attacking side");
// the defender's settings count against the attacker (a computer side here)
const auto trap = board(5, 1);
require(play_shift(even.data(), even.data(), nullptr, trap.data(), 1, 3, 30, false) < 0, "the offside trap helps a side that stands high");
require(play_shift(even.data(), even.data(), nullptr, trap.data(), 1, 0, 30, false) > 0, "the offside trap hurts a deep side");
const auto pressing = board(6, 1);
require(play_shift(even.data(), even.data(), pressing.data(), nullptr, 1, 1, 30, false) > base, "pressing brings chances in the first hour");
require(play_shift(even.data(), even.data(), pressing.data(), nullptr, 1, 1, 75, false) == base, "pressing brings nothing once the side is tired");
require(play_shift(even.data(), even.data(), nullptr, pressing.data(), 1, 1, 30, false) == 0, "a pressing side defends as usual at first");
require(play_shift(even.data(), even.data(), nullptr, pressing.data(), 1, 1, 75, false) > 0, "a tired pressing side lets the opponent through");
// everything at once stays within two steps of the chance roll
std::array<uint8_t, 8> all{0, 3, 3, 3, 0, 1, 1, 0};
for (int own_att = 0; own_att < 4; ++own_att)
for (int opp_att = 0; opp_att < 4; ++opp_att)
for (int minute : {10, 80}) {
const int shift = play_shift(strong.data(), weak.data(), all.data(), all.data(), own_att, opp_att, minute, false);
require(shift >= -4 && shift <= 4, "the shift is bounded");
}
std::puts("modern play shift tests passed");
return 0;
} catch (const std::exception& e) {
std::fprintf(stderr, "%s\n", e.what());
return 1;
}
}
+9
View File
@@ -17,6 +17,7 @@
#include <map>
#include <set>
#include <stdexcept>
#include <sstream>
#include <string>
#include "modern/app/modern_session.hpp"
@@ -502,6 +503,14 @@ int main(int argc, char** argv) {
int camp_stays = 0; // SIM_CAMP: training camp stays booked
int sponsor_offers = 0, sponsor_started = 0, sponsor_queued = 0; // SIM_SPONSOR
for (; played < turns; played++) {
// SIM_TACTICS=a,b,c,d,e,f,g,h: the manager keeps these eight tactic settings
// (manager record +0xd2..; -1 leaves a setting alone), to measure their effect
if (const char* tactics = std::getenv("SIM_TACTICS")) {
std::stringstream list(tactics);
std::string item;
for (size_t k = 0; k < 8 && std::getline(list, item, ','); ++k)
if (const int v = std::atoi(item.c_str()); v >= 0) g.manager_records.at(0xd2 + k) = uint8_t(v);
}
// SIM_ADVERTISING=1: the manager keeps his advertising places filled, as every
// player does (the largest income besides the gate): an expired contract is renewed
// when the sponsor offers it (legacy routine), a free place takes the best acceptable