Flop-Bibliothek: Einbindung in die Antwort testbar (mischung_fuer, bibliothek_antwort, exakt_text, ordner_von als reine Funktionen) und Specs dafuer (flopbib_dienst_spec.rs); Farm-Treiber prueft den Platz

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Marc Mintel
2026-12-05 12:12:48 +01:00
co-authored by Claude Opus 5.5
parent 5777b3ed4f
commit 069e439153
5 changed files with 254 additions and 74 deletions
+36 -71
View File
@@ -1494,28 +1494,13 @@ impl Motor {
// MOTOR_FLOP_BIBLIOTHEK (flopbib_nach.rs): Mischung aus der Flop-Bibliothek statt der Loesung, wo sie dasselbe Spiel ist
if let Some(ordner) = crate::flopbib_nach::ordner() {
match self.flop_bibliothek(ordner, q, &a, zuege, oop, ip, mich, hand, brett, bb) {
Ok((v, werte, text)) => {
if q["suche_frueh"] == true {
return Ok(Some(json!({"action": "ABSTAIN", "size": null, "confidence": 0, "reason": format!("suche_frueh: {text}")})));
}
let (i, akt, groesse) = ziehe(q, &v, salz, bb, stack == voll)?;
let zug_text = v.iter().map(|(a, p)| format!("{a:?} {:.0}%", p * 100.0)).collect::<Vec<_>>().join(", ");
let grund = format!("motor FLOP {text} ({} ms, Topf {} Rest {}): {zug_text}", t0.elapsed().as_millis(), a.pot, a.stack);
let werte_j: Vec<Value> = v.iter().enumerate().map(|(j, (x, p))| {
let (ar, zi) = match x { Action::Fold => (0, 0), Action::Check | Action::Call => (1, 0), Action::Bet(b) | Action::Raise(b) | Action::AllIn(b) => (2, *b), _ => (9, 0) };
json!([ar, zi as f64 / 100.0, p, werte.as_ref().map(|w| w[j]), Value::Null])
}).collect();
return Ok(Some(json!({"action": akt, "size": groesse, "confidence": v[i].1, "reason": grund, "werte": werte_j})));
}
Ok(m) => return bibliothek_antwort(q, &m, salz, bb, stack == voll, t0.elapsed().as_millis(), a.pot, a.stack).map(Some),
Err(e) => BIB_NOTIZ.with(|n| *n.borrow_mut() = Some(format!("Bibliothek: {e}"))),
}
}
let (k, g, ausbeutung, text) = self.flop_geloest(&a, &zuege_von(1), q["suche_frueh"] == true)?;
// MOTOR_FLOP_BIBLIOTHEK: Rueckfall auf Flop exakt - der Grund steht im Zuggrund (in der Klammer, die nl2.rs nicht liest)
let text = match BIB_NOTIZ.with(|n| n.borrow_mut().take()) {
Some(g) => format!("{text}; {g}"),
None => text,
};
let text = crate::flopbib_nach::exakt_text(text, BIB_NOTIZ.with(|n| n.borrow_mut().take()));
if q["suche_frueh"] == true {
let e = crate::flop_exakt::einstellung().as_ref().ok().cloned().flatten().ok_or("Einstellung")?;
crate::flop_exakt::merke(k, g, ausbeutung, e.merker_bytes);
@@ -1989,64 +1974,17 @@ impl Motor {
Ok((k, g, w))
}
/// MOTOR_FLOP_BIBLIOTHEK: Mischung der Hand aus der Flop-Bibliothek -> (Mischung mit Zuegen des echten Topfs, Werte je Zug in bb (flopbib-2),
/// Text fuer den Zuggrund); sonst der Grund, warum nicht.
/// MOTOR_FLOP_BIBLIOTHEK: Topfart und Linie aus dem Vorflop-Weg, dann die Mischung der Hand (`flopbib_nach::mischung_fuer`); sonst der Grund.
#[allow(clippy::too_many_arguments)]
fn flop_bibliothek(&self, ordner: &str, q: &Value, a: &Aufgabe, zuege: &[Echt], oop: usize, ip: usize, mich: usize, hand: (u8, u8), brett: &[u8], bb: f64) -> Result<(Vec<(Action, f32)>, Option<Vec<f32>>, String), String> {
fn flop_bibliothek(&self, ordner: &str, q: &Value, a: &Aufgabe, zuege: &[Echt], oop: usize, ip: usize, mich: usize, hand: (u8, u8), brett: &[u8], bb: f64) -> Result<crate::flopbib_nach::Mischung, String> {
use crate::flopbib_nach as fb;
let vorflop: Vec<(usize, u8)> = zuege.iter().filter(|e| e.strasse == 0).map(|e| (e.sitz as usize, e.art)).collect();
let (art, linie) = fb::lage_art(oop, ip, &vorflop)?;
let (iso, perm) = fb::iso_mit([brett[0], brett[1], brett[2]]);
let iso_t = crate::flopbib::flop_text(iso);
// Heads-up-Tisch (HU-Tafel): eigene Bilder unter hu/<art>; gleiche Liniennamen bedeuten dort andere Ranges
let hu = self.s.n == 2;
let tol = art.toleranz_fuer(hu);
let regel = crate::rake::regel(bb).and_then(|r| r.fuer_loeser(crate::rake::spieler(q)));
// Stufen derselben Linie (weitere Kopfzeilen: Ordner <linie>@<stufe>): die erste, deren Lage passt; sonst der Grund der Grundlinie
let unter = art.pfad(hu);
let mut gewaehlt: Option<(std::sync::Arc<Result<fb::Bild, String>>, f64, String)> = None;
let mut grund: Option<String> = None;
for l in fb::linien_mit_stufen(ordner, &unter, &linie) {
let bild = fb::bild(ordner, &unter, &l, &iso_t);
let pruef = match bild.as_ref() {
Ok(b) => fb::gleiche_lage(b, a.pot, a.stack, a.rake, fb::rake_zugelassen(regel, b.rake, tol), tol).map_err(|e| format!("{l} {iso_t}: {e}")),
Err(e) => Err(e.clone()),
};
match pruef {
Ok(skala) => {
gewaehlt = Some((bild.clone(), skala, l));
break;
}
Err(e) => {
grund.get_or_insert(e);
}
}
}
let Some((bild, skala, linie)) = gewaehlt else { return Err(grund.unwrap_or_else(|| format!("{unter}/{linie} {iso_t} fehlt"))) };
let b = bild.as_ref().as_ref().map_err(|e| e.clone())?;
let flop: Vec<(u8, i32)> = zuege.iter().filter(|e| e.strasse == 1).map(|e| (e.art, e.ziel.round() as i32)).collect();
let t = fb::nachschlagen(b, mich, &fb::hand_text(hand, perm), &flop, skala).map_err(|e| format!("{linie} {iso_t}: {e}"))?;
let v: Vec<(Action, f32)> = t
.mischung
.iter()
.map(|(z, p)| {
let x = match *z {
fb::Zug::Fold => Action::Fold,
fb::Zug::Check => Action::Check,
fb::Zug::Call => Action::Call,
fb::Zug::Bet(x) => Action::Bet(x.min(a.stack)),
fb::Zug::Raise(x) => Action::Raise(x.min(a.stack)),
fb::Zug::AllIn(_) => Action::AllIn(a.stack),
};
(x, *p)
})
.collect();
let summe: f32 = v.iter().map(|x| x.1).sum();
if summe <= 0.0 {
return Err("Mischung leer".into());
}
let v = v.into_iter().map(|(x, p)| (x, p / summe)).collect();
Ok((v, t.werte, format!("Bibliothek {} {linie} {iso_t} Luecke {:.2} %", art.pfad(hu), b.luecke_topf * 100.0)))
let regel = crate::rake::regel(bb).and_then(|r| r.fuer_loeser(crate::rake::spieler(q)));
// Heads-up-Tisch (HU-Tafel): eigene Bilder unter hu/<art>; gleiche Liniennamen bedeuten dort andere Ranges
let lage = fb::Lage { pot: a.pot, stack: a.stack, rake: a.rake, regel, hu: self.s.n == 2 };
fb::mischung_fuer(ordner, art, &linie, [brett[0], brett[1], brett[2]], hand, mich, &flop, &lage)
}
/// MOTOR_FLOP_EXAKT: Flop-Spiel aus dem Merker oder geloest, wenn die erwartete Zeit in die Frist passt (flop_exakt.rs).
@@ -2110,7 +2048,7 @@ impl Motor {
/// Schluessel einer Aufgabe fuer den Merker: Topf, Stapel, Brett, Ranges.
/// Zieht aus der Mischung `v` (Summe 1) mit dem Seed der Anfrage einen Zug und macht ihn zur Tisch-Aktion: (Index, Aktion, Groesse in Geld).
/// `voller_stapel`: der Baum hat den ganzen Stapel (All-in = maxRaiseTo).
fn ziehe(q: &Value, v: &[(Action, f32)], salz: u64, bb: f64, voller_stapel: bool) -> Result<(usize, &'static str, Option<f64>), String> {
pub(crate) fn ziehe(q: &Value, v: &[(Action, f32)], salz: u64, bb: f64, voller_stapel: bool) -> Result<(usize, &'static str, Option<f64>), String> {
let seed = q["seed"].as_u64().unwrap_or(1);
let w: Vec<f32> = v.iter().map(|x| x.1).collect();
let i = waehle(&mut Rng(misch(seed, salz) | 1), &w);
@@ -2136,6 +2074,33 @@ fn ziehe(q: &Value, v: &[(Action, f32)], salz: u64, bb: f64, voller_stapel: bool
Ok((i, akt, groesse))
}
/// MOTOR_FLOP_BIBLIOTHEK: Antwort aus der Mischung der Bibliothek (Zug mit dem Seed der Anfrage gezogen wie bei Flop exakt); bei
/// `suche_frueh` nur die Notiz, dass nichts vorzurechnen ist.
#[allow(clippy::too_many_arguments)]
pub(crate) fn bibliothek_antwort(q: &Value, m: &crate::flopbib_nach::Mischung, salz: u64, bb: f64, voller_stapel: bool, ms: u128, pot: i32, rest: i32) -> Result<Value, String> {
if q["suche_frueh"] == true {
return Ok(json!({"action": "ABSTAIN", "size": null, "confidence": 0, "reason": format!("suche_frueh: {}", m.text)}));
}
let v = &m.v;
let (i, akt, groesse) = ziehe(q, v, salz, bb, voller_stapel)?;
let zug_text = v.iter().map(|(a, p)| format!("{a:?} {:.0}%", p * 100.0)).collect::<Vec<_>>().join(", ");
let grund = format!("motor FLOP {} ({ms} ms, Topf {pot} Rest {rest}): {zug_text}", m.text);
let werte_j: Vec<Value> = v
.iter()
.enumerate()
.map(|(j, (x, p))| {
let (ar, zi) = match x {
Action::Fold => (0, 0),
Action::Check | Action::Call => (1, 0),
Action::Bet(b) | Action::Raise(b) | Action::AllIn(b) => (2, *b),
_ => (9, 0),
};
json!([ar, zi as f64 / 100.0, p, m.werte.as_ref().map(|w| w[j]), Value::Null])
})
.collect();
Ok(json!({"action": akt, "size": groesse, "confidence": v[i].1, "reason": grund, "werte": werte_j}))
}
fn schluessel(a: &Aufgabe) -> u64 {
let mut k = misch(a.pot as u64, a.stack as u64);
for c in &a.brett {
@@ -0,0 +1,118 @@
//! Spezifikation der Einbindung von MOTOR_FLOP_BIBLIOTHEK in die Antwort des Dienstes (dienst.rs `flop_bibliothek`, `bibliothek_antwort`,
//! `ziehe`; flopbib_nach.rs `mischung_fuer`, `exakt_text`, `ordner_von`): Treffer mit Zug, Zuggrund und Betrag; Rueckfall mit Grund, wenn
//! das Bild fehlt, die Lage oder die Rake nicht passt; am Heads-up-Tisch kein 6-max-Bild gleichen Namens; ohne Schalter kein Ordner.
use crate::dienst::{bibliothek_antwort, ziehe};
use crate::flopbib_nach::{exakt_text, mischung_fuer, ordner_von, spec::bild_roh, Lage, Topfart};
use postflop_solver::Action;
use serde_json::json;
fn k(s: &str) -> u8 {
let r = b"23456789TJQKA".iter().position(|&c| c == s.as_bytes()[0]).unwrap() as u8;
let f = b"cdhs".iter().position(|&c| c == s.as_bytes()[1]).unwrap() as u8;
r * 4 + f
}
/// Wurzel mit dem kleinen Bild (BTN-BB, Flop Ks7h2d) unter srp/bilder/BTN-BB/<Iso-Flop>.bin.
fn wurzel(name: &str) -> (String, [u8; 3]) {
let w = std::env::temp_dir().join(format!("flopbib-dienst-{name}-{}", std::process::id())).to_string_lossy().to_string();
let flop = [k("Ks"), k("7h"), k("2d")];
let iso = crate::flopbib::flop_text(crate::flopbib::kanonisch(flop));
std::fs::create_dir_all(format!("{w}/srp/bilder/BTN-BB")).unwrap();
std::fs::write(format!("{w}/srp/bilder/BTN-BB/{iso}.bin"), bild_roh(false)).unwrap();
(w, flop)
}
/// Eine echte Hand, die nach der Farbvertauschung des Flops die Bibliothekshand `ziel` ist.
fn hand_fuer(flop: [u8; 3], ziel: &str) -> (u8, u8) {
let (_, perm) = crate::flopbib_nach::iso_mit(flop);
(0..52u8).flat_map(|a| (a + 1..52).map(move |b| (a, b))).find(|&h| crate::flopbib_nach::hand_text(h, perm) == ziel).unwrap()
}
fn lage() -> Lage {
Lage { pot: 550, stack: 6600, rake: (0.05, 1000.0), regel: Some((0.05, 1000.0)), hu: false }
}
fn anfrage(seed: u64) -> serde_json::Value {
json!({"bigBlind": 0.02, "seed": seed, "toCall": 0.0, "minRaiseTo": 0.02, "maxRaiseTo": 1.32, "legalActions": ["FOLD", "CHECK", "RAISE"]})
}
#[test]
fn treffer_zug_kommt_aus_der_bibliothek_mit_zuggrund_und_betrag() {
let (w, flop) = wurzel("treffer");
let m = mischung_fuer(&w, Topfart::Srp, "BTN-BB", flop, hand_fuer(flop, "AdAh"), 0, &[], &lage()).unwrap();
assert_eq!(m.v.iter().map(|x| x.0).collect::<Vec<_>>(), vec![Action::Check, Action::Bet(275)]);
assert!((m.v[0].1 - 0.25).abs() < 1e-4 && (m.v[1].1 - 0.75).abs() < 1e-4);
assert!(m.text.starts_with("Bibliothek srp BTN-BB "), "{}", m.text);
// beide Zuege kommen bei verschiedenen Seeds vor; Betrag des Einsatzes = 275/100 bb
let mut gesehen = (false, false);
for seed in 1..40 {
let q = anfrage(seed);
let a = bibliothek_antwort(&q, &m, 7, 0.02, true, 3, 550, 6600).unwrap();
let (i, akt, groesse) = ziehe(&q, &m.v, 7, 0.02, true).unwrap();
assert_eq!(a["action"], akt);
assert_eq!(a["size"].as_f64(), groesse);
assert_eq!(a["confidence"].as_f64().map(|x| x as f32), Some(m.v[i].1));
let r = a["reason"].as_str().unwrap();
assert!(r.starts_with("motor FLOP Bibliothek srp BTN-BB ") && r.ends_with("Check 25%, Bet(275) 75%"), "{r}");
assert!(r.contains("(3 ms, Topf 550 Rest 6600)"), "{r}");
assert_eq!(a["werte"].as_array().unwrap().len(), 2);
match akt {
"CHECK" => gesehen.0 = true,
"RAISE" => {
gesehen.1 = true;
assert!((groesse.unwrap() - 0.055).abs() < 1e-9, "{groesse:?}");
}
x => panic!("{x}"),
}
}
assert!(gesehen.0 && gesehen.1);
// suche_frueh: nichts vorzurechnen
let mut q = anfrage(1);
q["suche_frueh"] = json!(true);
let a = bibliothek_antwort(&q, &m, 7, 0.02, true, 3, 550, 6600).unwrap();
assert_eq!(a["action"], "ABSTAIN");
assert!(a["reason"].as_str().unwrap().starts_with("suche_frueh: Bibliothek srp BTN-BB"));
let _ = std::fs::remove_dir_all(&w);
}
#[test]
fn rueckfall_mit_grund_wenn_bild_lage_oder_rake_nicht_passt() {
let (w, flop) = wurzel("rueckfall");
let h = hand_fuer(flop, "AdAh");
// Bild fehlt
let e = mischung_fuer(&w, Topfart::Srp, "CO-BB", flop, h, 0, &[], &lage()).unwrap_err();
assert!(e.starts_with("srp/CO-BB ") && e.ends_with("fehlt"), "{e}");
// Lage passt nicht (Topf weit ueber der Toleranz)
let e = mischung_fuer(&w, Topfart::Srp, "BTN-BB", flop, h, 0, &[], &Lage { pot: 2000, stack: 24000, ..lage() }).unwrap_err();
assert!(e.contains("Topf 2000 statt 550"), "{e}");
// Rake: anderer Satz; Limit ohne Regel
let e = mischung_fuer(&w, Topfart::Srp, "BTN-BB", flop, h, 0, &[], &Lage { regel: Some((0.04, 1000.0)), ..lage() }).unwrap_err();
assert!(e.contains("Rake"), "{e}");
let e = mischung_fuer(&w, Topfart::Srp, "BTN-BB", flop, h, 0, &[], &Lage { regel: None, ..lage() }).unwrap_err();
assert!(e.contains("Rake"), "{e}");
// Einsatz ausserhalb des Baums
let e = mischung_fuer(&w, Topfart::Srp, "BTN-BB", flop, hand_fuer(flop, "4c5c"), 1, &[(2, 450)], &lage()).unwrap_err();
assert!(e.contains("Groesse 450"), "{e}");
// der Grund landet im Zuggrund von Flop exakt; ohne Grund bleibt der Text
assert_eq!(exakt_text("1200 ms geloest".into(), Some(format!("Bibliothek: {e}"))), format!("1200 ms geloest; Bibliothek: {e}"));
assert_eq!(exakt_text("gemerkt".into(), None), "gemerkt");
let _ = std::fs::remove_dir_all(&w);
}
#[test]
fn heads_up_tisch_nimmt_kein_6max_bild_gleichen_namens() {
let (w, flop) = wurzel("hu");
let h = hand_fuer(flop, "AdAh");
let hu = Lage { hu: true, rake: (0.05, 250.0), regel: Some((0.05, 250.0)), ..lage() };
let e = mischung_fuer(&w, Topfart::Srp, "BTN-BB", flop, h, 0, &[], &hu).unwrap_err();
assert!(e.starts_with("hu/srp/BTN-BB ") && e.ends_with("fehlt"), "{e}");
let _ = std::fs::remove_dir_all(&w);
}
#[test]
fn ohne_schalter_kein_ordner() {
assert_eq!(ordner_von(|_| None), None);
assert_eq!(ordner_von(|_| Some(" ".into())), None);
assert_eq!(ordner_von(|k| (k == "MOTOR_FLOP_BIBLIOTHEK").then(|| " D:\\bib ".into())), Some("D:\\bib".into()));
assert_eq!(ordner_von(|k| (k == "ANDERES").then(|| "x".into())), None);
}
+86 -3
View File
@@ -51,7 +51,90 @@ const VORFLOP_REIHE: [usize; 6] = [2, 3, 4, 5, 0, 1];
pub fn ordner() -> Option<&'static str> {
static O: OnceLock<Option<String>> = OnceLock::new();
O.get_or_init(|| std::env::var("MOTOR_FLOP_BIBLIOTHEK").ok().filter(|x| !x.trim().is_empty())).as_deref()
O.get_or_init(|| ordner_von(|k| std::env::var(k).ok())).as_deref()
}
/// Liest ausschliesslich MOTOR_FLOP_BIBLIOTHEK; leer oder nicht gesetzt = aus.
pub fn ordner_von(umgebung: impl Fn(&str) -> Option<String>) -> Option<String> {
umgebung("MOTOR_FLOP_BIBLIOTHEK").map(|x| x.trim().to_string()).filter(|x| !x.is_empty())
}
/// Zuggrund von Flop exakt mit dem Grund, warum die Bibliothek nicht griff (in der Klammer, die nl2.rs nicht liest).
pub fn exakt_text(text: String, notiz: Option<String>) -> String {
match notiz {
Some(g) => format!("{text}; {g}"),
None => text,
}
}
/// Die echte Lage, wie der Dienst sie rechnet (Topf, Stapel in 1/100 bb; Rake wie `Aufgabe::rake`; `regel` = Satz/Deckel der Rake-Regel
/// des Limits fuer den Loeser; `hu` = Heads-up-Tisch mit HU-Tafel).
#[derive(Clone, Copy, Debug)]
pub struct Lage {
pub pot: i32,
pub stack: i32,
pub rake: (f64, f64),
pub regel: Option<(f64, f64)>,
pub hu: bool,
}
/// Mischung der Bibliothek fuer die Hand, Zuege auf den echten Topf skaliert, Summe 1; Werte je Zug (flopbib-2); Text fuer den Zuggrund.
#[derive(Clone, Debug)]
pub struct Mischung {
pub v: Vec<(postflop_solver::Action, f32)>,
pub werte: Option<Vec<f32>>,
pub text: String,
}
/// Bild der Linie (oder einer ihrer Stufen, deren Lage passt), Knoten ueber die echten Flop-Zuege, Mischung der Hand; sonst der Grund.
#[allow(clippy::too_many_arguments)]
pub fn mischung_fuer(wurzel: &str, art: Topfart, linie: &str, flop: [u8; 3], hand: (u8, u8), mich: usize, flop_zuege: &[(u8, i32)], lage: &Lage) -> Result<Mischung, String> {
use postflop_solver::Action;
let (iso, perm) = iso_mit(flop);
let iso_t = flopbib::flop_text(iso);
let tol = art.toleranz_fuer(lage.hu);
let unter = art.pfad(lage.hu);
let mut gewaehlt: Option<(Arc<Result<Bild, String>>, f64, String)> = None;
let mut grund: Option<String> = None;
for l in linien_mit_stufen(wurzel, &unter, linie) {
let bild = bild(wurzel, &unter, &l, &iso_t);
let pruef = match bild.as_ref() {
Ok(b) => gleiche_lage(b, lage.pot, lage.stack, lage.rake, rake_zugelassen(lage.regel, b.rake, tol), tol).map_err(|e| format!("{l} {iso_t}: {e}")),
Err(e) => Err(e.clone()),
};
match pruef {
Ok(skala) => {
gewaehlt = Some((bild.clone(), skala, l));
break;
}
Err(e) => {
grund.get_or_insert(e);
}
}
}
let Some((bild, skala, linie)) = gewaehlt else { return Err(grund.unwrap_or_else(|| format!("{unter}/{linie} {iso_t} fehlt"))) };
let b = bild.as_ref().as_ref().map_err(|e| e.clone())?;
let t = nachschlagen(b, mich, &hand_text(hand, perm), flop_zuege, skala).map_err(|e| format!("{linie} {iso_t}: {e}"))?;
let v: Vec<(Action, f32)> = t
.mischung
.iter()
.map(|(z, p)| {
let x = match *z {
Zug::Fold => Action::Fold,
Zug::Check => Action::Check,
Zug::Call => Action::Call,
Zug::Bet(x) => Action::Bet(x.min(lage.stack)),
Zug::Raise(x) => Action::Raise(x.min(lage.stack)),
Zug::AllIn(_) => Action::AllIn(lage.stack),
};
(x, *p)
})
.collect();
let summe: f32 = v.iter().map(|x| x.1).sum();
if summe <= 0.0 {
return Err("Mischung leer".into());
}
Ok(Mischung { v: v.into_iter().map(|(x, p)| (x, p / summe)).collect(), werte: t.werte, text: format!("Bibliothek {unter} {linie} {iso_t} Luecke {:.2} %", b.luecke_topf * 100.0) })
}
/// Zug der Bibliothek (Betraege in 1/100 bb wie im Loeser: Gesamteinsatz dieser Strasse).
@@ -490,7 +573,7 @@ pub fn lade_messung(wurzel: &str) -> Result<serde_json::Value, String> {
}
#[cfg(test)]
mod spec {
pub(crate) mod spec {
use super::*;
use serde_json::json;
@@ -634,7 +717,7 @@ mod spec {
}
/// Kleines Bild von Hand: Wurzel OOP (Check, Bet(275)), IP nach Check (Check, Bet(275)), IP nach Bet (Fold, Call, Raise(1100)).
fn bild_roh(format2: bool) -> Vec<u8> {
pub(crate) fn bild_roh(format2: bool) -> Vec<u8> {
let knoten = json!([
{"weg": [], "spieler": 0, "zuege": ["Check", "Bet(275)"]},
{"weg": [0], "spieler": 1, "zuege": ["Check", "Bet(275)"]},
+2
View File
@@ -17,6 +17,8 @@ mod flopwert;
mod flop_exakt;
mod flopbib;
mod flopbib_nach;
#[cfg(test)]
mod flopbib_dienst_spec;
mod groessen;
mod glueck;
mod karten;
@@ -13,6 +13,7 @@ ap.add_argument("--parallel", type=int, default=3)
ap.add_argument("--faeden", type=int, default=8)
ap.add_argument("--menue", default=None)
ap.add_argument("--zielluecke", default="1.0")
ap.add_argument("--min-frei-gb", type=float, default=5.0, help="vor jedem Schluessel: so viel muss auf dem Ziel-Laufwerk frei sein, sonst Ende")
ap.add_argument("--warte-stunden", type=float, default=6.0, help="so lange auf die Exe warten (Bau als eigener Auftrag)")
a = ap.parse_args()
bis = time.time() + a.warte_stunden * 3600
@@ -24,10 +25,21 @@ log = os.path.join(os.path.dirname(os.path.abspath(a.ziel)), f"fertig-{a.name}.j
keys = [z.split()[:2] for z in open(a.schluessel, encoding="utf-8") if z.strip()]
offen = [(l, f) for l, f in keys if not os.path.exists(os.path.join(a.ziel, l, f + ".bin"))]
print(f"{time.strftime('%H:%M:%S')} {len(keys)} Schluessel, {len(offen)} offen", flush=True)
if platz_gb() < a.min_frei_gb:
raise SystemExit(f"zu wenig Platz auf dem Ziel-Laufwerk: {platz_gb():.1f} GB frei, mindestens {a.min_frei_gb} GB")
import shutil
def platz_gb():
return shutil.disk_usage(os.path.splitdrive(os.path.abspath(a.ziel))[0] + os.sep).free / 1e9
def eins(k):
linie, flop = k
if platz_gb() < a.min_frei_gb:
return {"linie": linie, "flop": flop, "fehler": f"zu wenig Platz ({platz_gb():.1f} GB frei, mindestens {a.min_frei_gb} GB)"}
os.makedirs(os.path.join(a.ziel, linie), exist_ok=True)
aus = os.path.join(a.ziel, linie, flop + ".bin")
env = dict(os.environ, RAYON_NUM_THREADS=str(a.faeden), FLOPBIB_ZIEL=a.zielluecke)