Toto with up to six columns (Modern)

Each column costs the stake (10,000-400,000) and is settled on its own
with the original quotas; all columns stake 400,000 at most, every
column beyond the first adds a 10 % fee, no two columns alike. Column 1
stays on the original coupon; columns 2-6 and the last settlement live
in ModernState::pools and are saved. Session action
dispatch_pools_columns, read query {kind: "toto"}, unit test
modern_toto_tests, SIM_TOTO=<columns> in the season sim.

Measured over two seasons: 1 column returns 30-71 %, 6 columns 12-49 %
of the stakes; more columns win more often, never on average.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ClaudeandClaude Opus 5.5 committed 2026-10-24 11:06:57 +02:00
1 parent 4639fe5a91
commit 0aa0ed68ca
14 files changed
+357 -10

No files matched your search

+23
View File
@@ -1867,6 +1867,29 @@ bool submit_pools_coupon(ModernState& g, int manager, uint32_t stake,
return true;
}
// OpenBMH deviates from the original: the Modern Toto takes up to six columns (one in the original), each at the stake plus a 10 % fee per extra column, 400,000 at most in all.
PoolsColumnsResult submit_pools_columns(ModernState& g, int manager, uint32_t stake,
const std::vector<std::array<uint8_t, 11>>& columns) {
if (manager < 0 || size_t(manager) >= g.manager_teams.size()) return PoolsColumnsResult::invalid;
if (g.pools.size() < g.manager_teams.size()) g.pools.resize(g.manager_teams.size());
if (stake == 0) { // clears the coupon
if (!modern::submit_pools_coupon(g, manager, 0, columns.empty() ? std::array<uint8_t, 11>{} : columns[0]))
return PoolsColumnsResult::invalid;
g.pools[size_t(manager)].extra.clear();
return PoolsColumnsResult::ok;
}
if (columns.empty()) return PoolsColumnsResult::invalid;
if (columns.size() > size_t(kPoolsMaxColumns)) return PoolsColumnsResult::too_many_columns;
if (stake < 10'000 || stake > 400'000) return PoolsColumnsResult::stake_out_of_range;
if (uint64_t(stake) * columns.size() > kPoolsMaxTotalStake) return PoolsColumnsResult::total_too_high;
for (size_t a = 0; a < columns.size(); ++a)
for (size_t b = a + 1; b < columns.size(); ++b)
if (columns[a] == columns[b]) return PoolsColumnsResult::duplicate_column;
if (!modern::submit_pools_coupon(g, manager, stake, columns[0])) return PoolsColumnsResult::invalid;
g.pools[size_t(manager)].extra.assign(columns.begin() + 1, columns.end());
return PoolsColumnsResult::ok;
}
} // namespace bmh::modern
namespace bmh::modern {
+14
View File
@@ -270,6 +270,20 @@ bool build_stadium_investment_source(ModernState&, int manager, StadiumInvestmen
bool submit_pools_coupon(ModernState& g, int manager, uint32_t stake,
const std::array<uint8_t, 11>& tips);
// Modern Toto with up to six columns (docs/new_engine/toto.md): each column costs the stake
// (10,000-400,000) and is settled on its own with the original quotas; all columns together
// stake at most 400,000; every column beyond the first adds a fee of 10 % of the stake; no two
// columns alike. Column 1 goes to the original coupon. A stake of 0 clears every column.
constexpr int kPoolsMaxColumns = 6;
constexpr uint32_t kPoolsMaxTotalStake = 400'000;
enum class PoolsColumnsResult { ok, invalid, too_many_columns, stake_out_of_range, total_too_high, duplicate_column };
PoolsColumnsResult submit_pools_columns(ModernState& g, int manager, uint32_t stake,
const std::vector<std::array<uint8_t, 11>>& columns);
// What a coupon of `columns` columns costs at `stake` per column (stakes plus fee).
inline uint32_t pools_cost(uint32_t stake, size_t columns) {
return columns == 0 ? 0 : uint32_t(stake * columns + stake / 10 * (columns - 1));
}
} // namespace bmh::modern
namespace bmh::modern {
+25 -7
View File
@@ -19,6 +19,7 @@
#include "game/schedule.hpp"
#include "game/messages.hpp"
#include "game/table.hpp"
#include "modern/game/desk_actions.hpp"
#include "modern/game/weekly.hpp"
namespace bmh::modern {
@@ -1216,24 +1217,41 @@ void settle_pools_coupon(ModernState& g, const std::vector<MatchGroup>& groups)
if (mem.has(::bmh::layout::CareerSession_DispatchToto_RuntimeField)) mem.set8(::bmh::layout::CareerSession_DispatchToto_RuntimeField, uint8_t(k));
if (k <= 10) return;
static constexpr uint8_t kQuota[12] = {11, 10, 0, 20, 11, 10, 0, 1, 0, 10, 20, 50}; // MatchdaySetupRuntimeField13
if (g.pools.size() < g.manager_teams.size()) g.pools.resize(g.manager_teams.size());
for (size_t m = 0; m < g.manager_teams.size(); m++) {
const uint32_t at = ::bmh::layout::Coupon + uint32_t(m) * 0x14;
if (mem.u8(at + 3) & 0x80) mem.set32(at, 0);
auto& extra = g.pools[m].extra;
if (mem.u8(at + 3) & 0x80) mem.set32(at, 0), extra.clear();
const uint32_t stake = mem.u32(at);
if ((stake & 0x7fffffff) == 0) continue;
if (!modern::book_money(g, int(m), int32_t(stake), false, true)) {
// Modern: every column costs the stake, every one beyond the first 10 % more
// (docs/new_engine/toto.md); with one column this is the original booking.
const uint32_t cost = pools_cost(stake, 1 + extra.size());
if (!modern::book_money(g, int(m), int32_t(cost), false, true)) {
post_composed(g, int(m), message_text(g, ::bmh::layout::MatchdaySetup_SettlePoolsCoupon_TextPointer));
} else {
int hits = 0;
for (uint32_t i = 0; i < 0xb; i++)
if (mem.u8(at + 8 + i) == mem.u8(::bmh::layout::MatchdaySetup_EvaluatePoolsCoupon_RuntimeField + i)) hits++;
uint32_t win = 0;
if (hits > 8) win = stake * kQuota[hits];
auto hits_of = [&](auto tip) {
int hits = 0;
for (uint32_t i = 0; i < 0xb; i++)
if (tip(i) == mem.u8(::bmh::layout::MatchdaySetup_EvaluatePoolsCoupon_RuntimeField + i)) hits++;
return hits;
};
const int hits = hits_of([&](uint32_t i) { return mem.u8(at + 8 + i); });
uint32_t win = hits > 8 ? stake * kQuota[hits] : 0;
std::vector<uint8_t> column_hits{uint8_t(hits)};
for (const auto& column : extra) {
const int h = hits_of([&](uint32_t i) { return column[i]; });
column_hits.push_back(uint8_t(h));
if (h > 8) win += stake * kQuota[h];
}
mem.set32(at + 4, win);
mem.set8(at + 0x13, uint8_t(hits));
g.pools[m].hits = std::move(column_hits);
g.pools[m].paid = cost, g.pools[m].won = win;
modern::book_money(g, int(m), -int32_t(win), true, true);
}
mem.set32(at, 0); // (also clears the "settled" bit 7 of byte 3 just set)
extra.clear();
}
}
+11
View File
@@ -8,7 +8,9 @@
// always prefers the Modern season function over a Classic one of the same name.
// Modern-only data (world layout, UTF-8 names, ...) is added here, never to GameState.
#include <array>
#include <cstddef>
#include <cstdint>
#include <string>
#include <utility>
#include <vector>
@@ -52,6 +54,15 @@ struct ModernState : GameState {
std::vector<TrainingCamp> training_camps;
// The football almanac (docs/new_engine/almanach.md): every match of the career.
Almanac almanac;
// Toto with up to six columns (docs/new_engine/toto.md), per manager. Column 1 is the
// original coupon (Coupon + manager * 0x14); columns 2-6 and the last settlement live here.
struct PoolsColumns {
std::vector<std::array<uint8_t, 11>> extra; // columns 2-6, tips 1 home, 0 draw, 2 away
std::vector<uint8_t> hits; // hits per column of the last settlement
uint32_t paid = 0, won = 0; // stakes and fee, winnings of the last settlement
bool operator==(const PoolsColumns&) const = default;
};
std::vector<PoolsColumns> pools;
// Players whose age the data set gives (birth date); the others carry a placeholder the
// career start replaces as in the original. Needed only while a career starts (not saved).
std::vector<bool> world_age_known;