F6: bilanciamento con i bot su simulate

Banco di prova ripetibile per tarare l'economia (ADR 0025, obiettivi O1–O14
scritti prima della taratura):

- railenterprise-tools balance: semi × difficoltà × bot × anni in parallelo,
  rapporto deterministico (rapporto.txt con gli obiettivi, anni/mesi/prezzi/
  esecuzioni.csv, tempi.txt); simulate --bot <id>.
- Bot giocatore (PlayerBot): l'agente delle IA con le personalità di
  ai.json → bots guida la compagnia del giocatore; pianifica per primo; non
  è salvato né nell'hash, il formato dei salvataggi non cambia.
- Le IA usano la compravendita in proprio (supera ADR 0016 §9) con una regola
  mensile deterministica e parametri in ai.json → trading.
- Agente corretto: un trasformatore è fonte solo con gli input alimentati
  (prima i bot fallivano su linee rimaste senza merce finite le scorte
  iniziali); la linea dei ricambi di una rete nuova esce dal budget iniziale
  se l'utile la ripaga entro planning.partsDeferYears.
- Dati: market.world volumeShare 0,5 → 1,0 ed elasticity 1,0 → 2,5;
  townBonus 1,8 → 3,0, townRoiFactor 0,5 → 0,35.

Matrice predefinita (72 esecuzioni da 12 anni, 533 s): obiettivi da 5 a 9
su 14; livello 2 del bot competente in «Imprenditore» al 4° anno (prima 7°),
nessun fallimento dei bot in «Apprendista» e «Imprenditore», prezzi medi tra
0,77 e 1,42 volte il base (prima 0,38–2,78). Restano aperti O7–O11.

EconomyTests.PriceRisesWhenDemandExceedsSupply: la soglia passa da 1,5 a
1,25 volte in 120 giorni perché il mondo a volume pieno ed elasticità 2,5
assorbe parte dello squilibrio (aumento misurato ~1,36). Accettazioni F2, F4
e F5 invariate e verdi; 222 test verdi.

Refs #47.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-08 16:30:31 +01:00
1 parent 2e781bbba2
commit 3d394c01d3
22 files changed
+1336 -28

No files matched your search

+18 -3
View File
@@ -36,11 +36,12 @@
"commuterCoverage": 0.6,
"hubShare": 0.25,
"noPartsFactor": 0.5,
"townBonus": 1.8,
"townRoiFactor": 0.5,
"townBonus": 3.0,
"townRoiFactor": 0.35,
"repayCashMonths": 12,
"planningDaySpacing": 7,
"failedMemory": 64
"failedMemory": 64,
"partsDeferYears": 3.0
},
"market": {
"founderAcceptPremium": 0.4,
@@ -63,11 +64,25 @@
"cashReserveMultiple": 2.0,
"maxTrainsPerMonth": 1
},
"trading": {
"enabled": true,
"minMargin": 0.25,
"priceSlack": 0.06,
"minSellPriceShare": 0.9,
"maxUnits": 150,
"maxTradesPerMonth": 2,
"cashShare": 0.15,
"cashReserveMultiple": 2.0
},
"personalities": [
{ "id": "expansive", "name_it": "Espansiva", "roiThreshold": 0.08, "loanShareOfCredit": 0.8, "targetsPlayer": false, "buysShares": false, "maintenancePolicy": "standard" },
{ "id": "prudent", "name_it": "Prudente", "roiThreshold": 0.15, "loanShareOfCredit": 0.3, "targetsPlayer": false, "buysShares": false, "maintenancePolicy": "standard" },
{ "id": "predatory", "name_it": "Predatoria", "roiThreshold": 0.10, "loanShareOfCredit": 0.6, "targetsPlayer": true, "buysShares": true, "maintenancePolicy": "standard" }
],
"bots": [
{ "id": "bot_competent", "name_it": "Bot competente", "roiThreshold": 0.10, "loanShareOfCredit": 0.6, "targetsPlayer": false, "buysShares": false, "maintenancePolicy": "standard" },
{ "id": "bot_prudent", "name_it": "Bot prudente", "roiThreshold": 0.18, "loanShareOfCredit": 0.25, "targetsPlayer": false, "buysShares": false, "maintenancePolicy": "thorough" }
],
"companyNames": [
"Strade Ferrate del Nord", "Società Ferroviaria Adriatica", "Compagnia delle Valli", "Ferrovie Meridionali",
"Società Anonima delle Strade Ferrate", "Ferrovia Alta Valle", "Compagnia Lombardo-Veneta", "Rete del Litorale"
+1 -1
View File
@@ -47,7 +47,7 @@
"maxPriceFactor": 3.0,
"ratioMin": 0.2,
"ratioMax": 5.0,
"world": { "amplitude": 0.12, "periodYears": 6, "volumeShare": 0.5, "baselinePerDay": 4.0, "elasticity": 1.0,
"world": { "amplitude": 0.12, "periodYears": 6, "volumeShare": 1.0, "baselinePerDay": 4.0, "elasticity": 2.5,
"shockChancePerYear": 0.25, "shockMin": 0.08, "shockMax": 0.30, "shockDecayDays": 150, "priceFloor": 0.05 },
"historyDays": 720,
"outlook": { "historyMonths": 24, "changeDays": 30, "forecastMonths": 4, "forecastBandPerMonth": 0.03, "sellPlaces": 3, "eventThreshold": 0.05 }
+105 -1
View File
@@ -74,6 +74,57 @@
},
"minItems": 3
},
"bots": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"pattern": "^[a-z][a-z0-9_]*$"
},
"name_it": {
"type": "string",
"minLength": 1
},
"roiThreshold": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"loanShareOfCredit": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"targetsPlayer": {
"type": "boolean"
},
"buysShares": {
"type": "boolean"
},
"maintenancePolicy": {
"type": "string",
"enum": [
"economy",
"standard",
"thorough"
]
}
},
"required": [
"id",
"name_it",
"roiThreshold",
"loanShareOfCredit",
"targetsPlayer",
"buysShares",
"maintenancePolicy"
],
"additionalProperties": false
},
"minItems": 1
},
"companyNames": {
"type": "array",
"items": {
@@ -119,6 +170,57 @@
],
"additionalProperties": false
},
"trading": {
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
},
"minMargin": {
"type": "number",
"minimum": 0,
"maximum": 5
},
"priceSlack": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"minSellPriceShare": {
"type": "number",
"minimum": 0,
"maximum": 3
},
"maxUnits": {
"type": "integer",
"minimum": 1
},
"maxTradesPerMonth": {
"type": "integer",
"minimum": 0
},
"cashShare": {
"type": "number",
"minimum": 0,
"maximum": 1
},
"cashReserveMultiple": {
"type": "number",
"minimum": 0
}
},
"required": [
"enabled",
"minMargin",
"priceSlack",
"minSellPriceShare",
"maxUnits",
"maxTradesPerMonth",
"cashShare",
"cashReserveMultiple"
],
"additionalProperties": false
},
"market": {
"type": "object",
"additionalProperties": {
@@ -137,7 +239,9 @@
"companyNames",
"colors",
"market",
"renewal"
"renewal",
"trading",
"bots"
],
"additionalProperties": false
}