|
|
|
@@ -84,9 +84,39 @@ pub fn splash() -> bool {
|
|
|
|
|
*A.get_or_init(|| an() && std::env::var("MOTOR_SHARINGAN_SPLASH").is_ok_and(|x| x == "1"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// MOTOR_SHARINGAN_PI=1 (04.12., Standard aus; Messweg des LBR, Tor 3): die Antwort traegt zusaetzlich `pi` = [[art, groesse_bb, p], ...]
|
|
|
|
|
/// (seine ganze Mischung am Punkt, art 0 Fold, 1 Check/Call, 2 Einsatz mit Betrag in bb) und `gezogen` (Index des gespielten Eintrags).
|
|
|
|
|
/// Ohne den Schalter bleibt jede Anfrage an seinen Dienst und jede Antwort Byte fuer Byte wie vorher.
|
|
|
|
|
pub fn pi_an() -> bool {
|
|
|
|
|
static A: OnceLock<bool> = OnceLock::new();
|
|
|
|
|
*A.get_or_init(|| an() && std::env::var("MOTOR_SHARINGAN_PI").is_ok_and(|x| x == "1"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Seine Mischung (`probs`: [{type, to, p}], `to` in Chips mit BB = 100) als `pi` und der Index des gespielten Zugs (`aktion`: {type, to}).
|
|
|
|
|
/// None: keine Mischung in der Antwort oder der gespielte Zug steht nicht darin.
|
|
|
|
|
pub fn pi_aus(probs: &Value, aktion: &Value) -> Option<(Value, usize)> {
|
|
|
|
|
let l = probs.as_array().filter(|l| !l.is_empty())?;
|
|
|
|
|
let art = |k: &str| match k {
|
|
|
|
|
"fold" => 0,
|
|
|
|
|
"check" | "call" => 1,
|
|
|
|
|
_ => 2,
|
|
|
|
|
};
|
|
|
|
|
let pi: Vec<Value> = l.iter().map(|x| json!([art(x["type"].as_str().unwrap_or("")), x["to"].as_f64().map_or(0.0, |t| t / 100.0), x["p"].as_f64().unwrap_or(0.0)])).collect();
|
|
|
|
|
let g = l.iter().position(|x| x["type"] == aktion["type"] && x["to"] == aktion["to"])?;
|
|
|
|
|
Some((json!(pi), g))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Zuggrund vor dem Flop, wenn totes Geld oder ein Nachpost im Topf liegt (seine Tabellen kennen beides nicht)
|
|
|
|
|
const GRUND_SPLASH: &str = " [Splash: Vorflop-Tabelle ohne totes Geld]";
|
|
|
|
|
const GRUND_NACHPOST: &str = " [Nachpost: Vorflop-Tabelle ohne Nachpost]";
|
|
|
|
|
const GRUND_SPLASH: &str = " [Splash: Tabelle ohne Splash-Knoten; Topf mit totem Geld]";
|
|
|
|
|
const GRUND_NACHPOST: &str = " [Nachpost: Tabelle ohne Nachpost-Knoten; Nachpost als Einsatz im Topf]";
|
|
|
|
|
|
|
|
|
|
/// MOTOR_REIN_ROH=1 (03.12., Owner "weg mit den heuristiken"; nur mit MOTOR_SHARINGAN_REIN, Standard aus): keine Antwort dieses Prozesses
|
|
|
|
|
/// geht durch unsere NL2-Nachschicht (Abgleich, Stack-off, Bluffpreis) - auch nicht der Rueckfall auf unseren Motor und nicht Straddle.
|
|
|
|
|
/// Reihenfolge bleibt: seine Suche, dann seine Tabelle (Blueprint), dann unser Motor roh.
|
|
|
|
|
pub fn rein_roh() -> bool {
|
|
|
|
|
static A: OnceLock<bool> = OnceLock::new();
|
|
|
|
|
*A.get_or_init(|| rein() && std::env::var("MOTOR_REIN_ROH").is_ok_and(|x| x == "1"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn schalter(k: &str, w: &str) -> bool {
|
|
|
|
|
std::env::var(k).is_ok_and(|x| x == w)
|
|
|
|
@@ -584,6 +614,14 @@ fn frage_roh(v: &Value) -> Option<Value> {
|
|
|
|
|
pub fn zug(q: &Value, k: &Kontext) -> Option<Value> {
|
|
|
|
|
let r = frage(&json!({"op": "act", "req": k.basis}))?;
|
|
|
|
|
let grund = if q["street"] == "PREFLOP" { k.vorflop_grund } else { "" };
|
|
|
|
|
// MOTOR_SHARINGAN_PI: der act-Weg traegt keine Mischung; dieselbe Lage nochmal als probs fragen (Blueprint, ohne Ziehen)
|
|
|
|
|
if pi_an() {
|
|
|
|
|
if let Some(p) = frage(&json!({"op": "probs", "req": k.basis})) {
|
|
|
|
|
let mut o = r["response"].clone();
|
|
|
|
|
o["probs"] = p["probs"].clone();
|
|
|
|
|
return abbilden(q, &o, grund.to_string());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
abbilden(q, &r["response"], grund.to_string())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -615,8 +653,15 @@ fn abbilden(q: &Value, o: &Value, zusatz: String) -> Option<Value> {
|
|
|
|
|
akt = if legal("CHECK") { "CHECK" } else if legal("CALL") && akt != "FOLD" { "CALL" } else { "FOLD" };
|
|
|
|
|
groesse = None;
|
|
|
|
|
}
|
|
|
|
|
Some(json!({"action": akt, "size": groesse, "confidence": 1,
|
|
|
|
|
"reason": format!("sharingan {} ({}){zusatz}", o["source"].as_str().unwrap_or("?"), o["street"].as_str().unwrap_or("?"))}))
|
|
|
|
|
let mut antwort = json!({"action": akt, "size": groesse, "confidence": 1,
|
|
|
|
|
"reason": format!("sharingan {} ({}){zusatz}", o["source"].as_str().unwrap_or("?"), o["street"].as_str().unwrap_or("?"))});
|
|
|
|
|
if pi_an() {
|
|
|
|
|
if let Some((pi, g)) = pi_aus(&o["probs"], a) {
|
|
|
|
|
antwort["pi"] = pi;
|
|
|
|
|
antwort["gezogen"] = json!(g);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Some(antwort)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------ MOTOR_SUCHE_QUELLE=sharingan (Echtzeit-Suche)
|
|
|
|
@@ -764,6 +809,9 @@ pub fn such_zug(q: &Value, k: &Kontext) -> Option<Value> {
|
|
|
|
|
// ohnehin nicht mehr nehmen; was wir nehmen, hat die volle feste Iterationszahl
|
|
|
|
|
let sein_ms = (rest * 1000.0 / 0.7) as u64 + 100;
|
|
|
|
|
let mut frage = json!({"op": "suche", "req": such_basis(k), "budget_ms": sein_ms});
|
|
|
|
|
if pi_an() {
|
|
|
|
|
frage["mit_probs"] = json!(true);
|
|
|
|
|
}
|
|
|
|
|
// MOTOR_SUCHE_BUDGET=1: weniger Iterationen nur, wenn die volle Zahl nicht mehr in die Frist passt
|
|
|
|
|
let knapp = if budget_an() && flop_n.is_none() { knappe_iters(rest) } else { None };
|
|
|
|
|
if let Some(n) = flop_n {
|
|
|
|
@@ -1200,7 +1248,7 @@ mod splash_spec {
|
|
|
|
|
// der Splash kommt nicht aus dem Stapel des Helden (Platz 1 -> sein Platz 0)
|
|
|
|
|
assert_eq!(k.basis["players"][0]["stack_start"], 10_000);
|
|
|
|
|
assert!(k.basis["players"].as_array().unwrap().iter().all(|p| p.get("dead").is_none() && p.get("live_post").is_none()));
|
|
|
|
|
assert_eq!(k.vorflop_grund, " [Splash: Vorflop-Tabelle ohne totes Geld]");
|
|
|
|
|
assert_eq!(k.vorflop_grund, super::GRUND_SPLASH);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
@@ -1210,7 +1258,7 @@ mod splash_spec {
|
|
|
|
|
assert_eq!(k.basis["players"][3]["dead"], 50);
|
|
|
|
|
assert_eq!(k.basis["players"][3]["stack_start"], 10_050); // Stapel jetzt + Ante
|
|
|
|
|
assert!(k.basis.get("dead_money").is_none());
|
|
|
|
|
assert_eq!(k.vorflop_grund, " [Splash: Vorflop-Tabelle ohne totes Geld]");
|
|
|
|
|
assert_eq!(k.vorflop_grund, super::GRUND_SPLASH);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
@@ -1223,7 +1271,7 @@ mod splash_spec {
|
|
|
|
|
assert_eq!(h.len(), 3); // SB, BB, Call; der Nachpost steht nur in players
|
|
|
|
|
assert_eq!(h[2]["type"], "call");
|
|
|
|
|
assert!(k.basis.get("dead_money").is_none());
|
|
|
|
|
assert_eq!(k.vorflop_grund, " [Nachpost: Vorflop-Tabelle ohne Nachpost]");
|
|
|
|
|
assert_eq!(k.vorflop_grund, super::GRUND_NACHPOST);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
@@ -1244,3 +1292,37 @@ mod splash_spec {
|
|
|
|
|
assert_eq!(b.vorflop_grund, "");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
mod pi_spec {
|
|
|
|
|
use super::pi_aus;
|
|
|
|
|
use serde_json::json;
|
|
|
|
|
|
|
|
|
|
fn probs() -> serde_json::Value {
|
|
|
|
|
json!([{"type": "raise", "to": 200, "p": 0.8}, {"type": "raise", "to": 250, "p": 0.14}, {"type": "call", "to": 100, "p": 0.06}, {"type": "fold", "p": 0.0}])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn mischung_wird_pi_mit_art_betrag_und_p() {
|
|
|
|
|
let (pi, g) = pi_aus(&probs(), &json!({"type": "raise", "to": 250})).unwrap();
|
|
|
|
|
assert_eq!(pi, json!([[2, 2.0, 0.8], [2, 2.5, 0.14], [1, 1.0, 0.06], [0, 0.0, 0.0]]));
|
|
|
|
|
assert_eq!(g, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn gespielter_zug_ausserhalb_der_mischung_gibt_nichts() {
|
|
|
|
|
assert!(pi_aus(&probs(), &json!({"type": "raise", "to": 999})).is_none());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn ohne_mischung_nichts() {
|
|
|
|
|
assert!(pi_aus(&json!(null), &json!({"type": "call", "to": 100})).is_none());
|
|
|
|
|
assert!(pi_aus(&json!([]), &json!({"type": "call", "to": 100})).is_none());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn fold_ohne_betrag_wird_gefunden() {
|
|
|
|
|
let (_, g) = pi_aus(&probs(), &json!({"type": "fold"})).unwrap();
|
|
|
|
|
assert_eq!(g, 3);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|