Merge branch 'refs/heads/claude/hybrid-suche'
This commit is contained in:
@@ -57,6 +57,8 @@ BEKANNTE_SCHALTER = ("FAUSTREGEL", "DROSSEL", "MDF_UNREAD", "RAISE_DRAWS", "RAIS
|
||||
# Hybrid (29.11. abends, Standard aus): Vorflop/Flop von SHARINGAN, entscheiden/motor/src/sharingan.rs
|
||||
"MOTOR_VORFLOP_FLOP_QUELLE", "MOTOR_HYB_UEBERSETZUNG", "MOTOR_HYB_FLOP_SUCHE", "MOTOR_HYB_RAKE",
|
||||
"MOTOR_SHARINGAN_WARTEN", "MOTOR_SHARINGAN_FRIST_MS", "MOTOR_SHARINGAN_FAEDEN", "MOTOR_SHARINGAN_ADRESSE", "MOTOR_SHARINGAN_EXE",
|
||||
# SHARINGAN-Suche (29.11. spaet, Standard aus): Turn/River und Flop aus seiner Echtzeit-Suche, entscheiden/motor/src/sharingan.rs
|
||||
"MOTOR_SUCHE_QUELLE", "MOTOR_SUCHE_ITERS", "MOTOR_SUCHE_FAEDEN", "MOTOR_SUCHE_DECKEL", "MOTOR_SUCHE_PUFFER", "MOTOR_SUCHE_ADRESSE", "MOTOR_SUCHE_EXE",
|
||||
# VERTRAUEN, 29.11., Standard aus: Ausbeutung nach Limit und Spieler dosiert, entscheiden/vertrauen.py
|
||||
"VERTRAUEN", "VERTRAUEN_POOL",
|
||||
# Denkzeit (29.11., Standard aus): MOTOR_TEMPO_TELL liest lesen/spot_from_log.py (Gegnerzeit -> tempoLR) und der
|
||||
@@ -86,6 +88,8 @@ LAEUFER_SCHALTER = ("AUSWAHL_FREI", "TISCHWAHL", "TISCHWAHL_AB", "TISCHWAHL_WART
|
||||
# Hybrid (29.11. abends, Standard aus): Vorflop/Flop von SHARINGAN, entscheiden/motor/src/sharingan.rs
|
||||
"MOTOR_VORFLOP_FLOP_QUELLE", "MOTOR_HYB_UEBERSETZUNG", "MOTOR_HYB_FLOP_SUCHE", "MOTOR_HYB_RAKE",
|
||||
"MOTOR_SHARINGAN_WARTEN", "MOTOR_SHARINGAN_FRIST_MS", "MOTOR_SHARINGAN_FAEDEN", "MOTOR_SHARINGAN_ADRESSE", "MOTOR_SHARINGAN_EXE",
|
||||
# SHARINGAN-Suche (29.11. spaet, Standard aus): Turn/River und Flop aus seiner Echtzeit-Suche, entscheiden/motor/src/sharingan.rs
|
||||
"MOTOR_SUCHE_QUELLE", "MOTOR_SUCHE_ITERS", "MOTOR_SUCHE_FAEDEN", "MOTOR_SUCHE_DECKEL", "MOTOR_SUCHE_PUFFER", "MOTOR_SUCHE_ADRESSE", "MOTOR_SUCHE_EXE",
|
||||
# VERTRAUEN, 29.11., Standard aus: Ausbeutung nach Limit und Spieler dosiert, entscheiden/vertrauen.py
|
||||
"VERTRAUEN", "VERTRAUEN_POOL",
|
||||
# Denkzeit (29.11., Standard aus): MOTOR_TEMPO_TELL liest lesen/spot_from_log.py (Gegnerzeit -> tempoLR) und der
|
||||
@@ -98,7 +102,7 @@ LAEUFER_SCHALTER = ("AUSWAHL_FREI", "TISCHWAHL", "TISCHWAHL_AB", "TISCHWAHL_WART
|
||||
# Notbremse je Schalter (29.11., Standard aus): betrieb/notbremse_lauf.py, lesen/notbremse.py
|
||||
"NOTBREMSE", "NOTBREMSE_MARKEN")
|
||||
# Pfade gehoeren nicht in die Arm-Marke.
|
||||
OHNE_MARKE = ("VERTRAUEN_POOL", "GRUNDSTRATEGIE", "GEGNER_LINIEN", "VORWISSEN", "MOTOR_SCHATTEN", "TURNIER_MOTOR", "MOTOR_SHARINGAN_EXE", "MOTOR_SHARINGAN_ADRESSE")
|
||||
OHNE_MARKE = ("VERTRAUEN_POOL", "GRUNDSTRATEGIE", "GEGNER_LINIEN", "VORWISSEN", "MOTOR_SCHATTEN", "TURNIER_MOTOR", "MOTOR_SHARINGAN_EXE", "MOTOR_SHARINGAN_ADRESSE", "MOTOR_SUCHE_EXE", "MOTOR_SUCHE_ADRESSE")
|
||||
|
||||
|
||||
def lies_schalter(pfad=SCHALTER_DATEI):
|
||||
|
||||
@@ -11,4 +11,8 @@ Schalter `MOTOR_VORFLOP_FLOP_QUELLE=sharingan` (Standard aus; Brücke `entscheid
|
||||
gekennzeichnet): `api.rs` bekommt `options.track_seed` (Seed der Übersetzung beim Nachspielen, je Hand fest), `decide.rs`
|
||||
liest `HYBRID_UEBERSETZUNG=phm` (seine `Translation::Random`, pseudo-harmonisch nach Ganzfried/Sandholm) und
|
||||
`HYBRID_ALLIN_SNAP` (Standard 0,1 bei phm statt 0,5). Ohne diese Umgebung und ohne track_seed verhält er sich wie vorher. Die Datei hier ist eine Kopie zum Nachvollziehen; gebaut wird sie in seinem Baum unter D:/pokerfreak-fremd.
|
||||
- Suche (29.11. spät, `MOTOR_SUCHE_QUELLE=sharingan`, Standard aus): `sharingan-hybrid.rs` hat zusätzlich `{"op":"suche"}` (seine
|
||||
Echtzeit-Suche über denselben `Core::decide`, `options.search` an). Mit `HYBRID_SUCHE=1` startet derselbe Dienst mit Suche statt
|
||||
`--no-search` (eigener Prozess `pokerbench-hybrid-suche.exe`, Port 47127; feste Iterationszahl `HYBRID_SUCHE_ITERS`, Standard 24000,
|
||||
`HYBRID_SUCHE_FAEDEN` 4). Sein Such-Code ist unverändert; die Suche ist rakefrei (bekannte Lücke).
|
||||
- Nichts davon wird weitergegeben; Code und Gewichte bleiben auf diesem Rechner.
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
//! {"op":"probs","req":<ActRequest>} -> {"ok":true,"source":..,"probs":[{"type","to","p"}]}: ganze Verteilung, ohne Ziehen
|
||||
//! (fuer die Angreifer-Probe gegen den Hybrid, angreifer_bewerten mit ANGREIFER_OPFER=hybrid)
|
||||
//! {"op":"ping"} -> {"ok":true}
|
||||
//! {"op":"suche","req":<ActRequest>,"budget_ms":n} -> wie act, aber mit seiner Echtzeit-Suche (nur im Suchmodus, sonst Blueprint).
|
||||
//! budget_ms geht als time_budget_ms in seinen Core (harte Frist, danach Blueprint mit source "fallback").
|
||||
//! HYBRID_SUCHE=1 (29.11. abends, Zusatz MOTOR_SUCHE_QUELLE=sharingan): Dienst mit Suche, feste Iterationszahl statt Uhr
|
||||
//! (HYBRID_SUCHE_ITERS, Standard 24000 (29.11.: 4 Faeden, 20000 -> Turn p50 0,35 s, p90 1,6 s; 24000 also p90 rund 2 s); HYBRID_SUCHE_FAEDEN Standard 4; Flop-Suche an: --set iters=N,flop=1).
|
||||
//! Ohne HYBRID_SUCHE wie bisher --no-search; act/probs/range rechnen in beiden Arten ohne Suche.
|
||||
//! HYBRID_LEERLAUF_S (Standard 900): ohne offene Verbindung so lange still -> beenden (gibt den Speicher frei).
|
||||
use rayon::prelude::*;
|
||||
use serde_json::{json, Value};
|
||||
@@ -121,6 +126,19 @@ fn bediene_innen(core: Arc<Core>, pool: Arc<rayon::ThreadPool>, s: TcpStream) {
|
||||
}
|
||||
}
|
||||
},
|
||||
Some("suche") => match serde_json::from_value::<ActRequest>(v["req"].clone()) {
|
||||
Err(e) => json!({"ok": false, "error": e.to_string()}),
|
||||
Ok(mut req) => {
|
||||
req.options.search = true;
|
||||
req.options.include_probs = false;
|
||||
req.options.time_budget_ms = v["budget_ms"].as_u64().filter(|&b| b > 0);
|
||||
match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| core.decide(&req, core.next_request_id()))) {
|
||||
Ok(Ok(a)) => json!({"ok": true, "response": a}),
|
||||
Ok(Err(e)) => json!({"ok": false, "error": e.body()}),
|
||||
Err(_) => json!({"ok": false, "error": "panic"}),
|
||||
}
|
||||
}
|
||||
},
|
||||
Some("probs") => match serde_json::from_value::<ActRequest>(v["req"].clone()) {
|
||||
Err(e) => json!({"ok": false, "error": e.to_string()}),
|
||||
Ok(mut req) => {
|
||||
@@ -155,7 +173,19 @@ fn main() {
|
||||
if !args.iter().any(|a| a == "--no-auth") {
|
||||
args.push("--no-auth".into());
|
||||
}
|
||||
if !args.iter().any(|a| a == "--no-search") {
|
||||
let suche = std::env::var("HYBRID_SUCHE").is_ok_and(|x| x == "1");
|
||||
if suche {
|
||||
let it = std::env::var("HYBRID_SUCHE_ITERS").unwrap_or_else(|_| "24000".into());
|
||||
let fd = std::env::var("HYBRID_SUCHE_FAEDEN").unwrap_or_else(|_| "4".into());
|
||||
// Uhr nur als Sicherung: budget 600 s (der Motor setzt je Frage seine Frist als time_budget_ms), Warteschlange 20 ms
|
||||
for (k, v) in [("--search-threads", fd), ("--search-concurrency", "2".into()), ("--budget-ms", "600000".into()),
|
||||
("--queue-ms", "20".into()), ("--set", format!("iters={it},flop=1"))] {
|
||||
if !args.iter().any(|a| a == k) {
|
||||
args.push(k.into());
|
||||
args.push(v);
|
||||
}
|
||||
}
|
||||
} else if !args.iter().any(|a| a == "--no-search") {
|
||||
args.push("--no-search".into());
|
||||
}
|
||||
let mut cfg = match Config::parse(&|k| std::env::var(k).ok(), &args) {
|
||||
|
||||
@@ -519,6 +519,19 @@ impl Motor {
|
||||
fn versuche(&self, q: &Value) -> Result<Value, String> {
|
||||
let _hybrid = if crate::sharingan::an() { Some(crate::sharingan::Wache::setze(self.hybrid(q).then(|| crate::sharingan::Kontext::aus(q)).flatten())) } else { None };
|
||||
if let Some(k) = _hybrid.as_ref().and_then(|_| crate::sharingan::kontext()) {
|
||||
// MOTOR_SUCHE_QUELLE=sharingan: seine Suche auf Turn/River und auf dem Flop, wo sonst sein Blueprint spielt
|
||||
if crate::sharingan::suche_an() {
|
||||
let st = q["street"].as_str().unwrap_or("");
|
||||
let rnr = crate::sharingan::suche_ausser_rnr() && rnr_sperre_greift(q);
|
||||
if rnr {
|
||||
crate::sharingan::protokoll_marke("suche-rnr");
|
||||
}
|
||||
if !rnr && (matches!(st, "TURN" | "RIVER") || (st == "FLOP" && !k.motor_spielt(st))) {
|
||||
if let Some(a) = crate::sharingan::such_zug(q, &k) {
|
||||
return Ok(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
if matches!(q["street"].as_str(), Some("PREFLOP" | "FLOP")) && !k.motor_spielt(q["street"].as_str().unwrap_or("")) {
|
||||
if let Some(a) = crate::sharingan::zug(q, &k) {
|
||||
return Ok(a);
|
||||
@@ -1885,6 +1898,24 @@ pub fn summe(name: &str, haende: usize) {
|
||||
}
|
||||
|
||||
/// VERTRAUEN: p der Anfrage in [0, 1]; fehlt es oder ist es kaputt: 1 (Ausbeutung wie bisher).
|
||||
/// Greift unsere RNR-/NL2-Sperre an diesem Punkt? Dieselbe Bedingung wie `sperre` in der Nachrechnung (dort unveraendert):
|
||||
/// River ohne offenen Einsatz mit MOTOR_RNR (p aus vertrauen_p/MOTOR_RNR_P) oder MOTOR_NL2LOCK; mit MOTOR_RNR_MODELL=pool auch
|
||||
/// gegen Einsatz (MOTOR_RNR_GEGEN) und am Turn (MOTOR_RNR_TURN). Fuer MOTOR_SUCHE_QUELLE=sharingan_ausser_rnr.
|
||||
pub fn rnr_sperre_greift(q: &Value) -> bool {
|
||||
let strasse = match q["street"].as_str() {
|
||||
Some("TURN") => 2,
|
||||
Some("RIVER") => 3,
|
||||
_ => return false,
|
||||
};
|
||||
let rnr = nachrechnen::rnr_p().is_some();
|
||||
let offen = q["toCall"].as_f64().unwrap_or(0.0) > 0.0;
|
||||
let pool = rnr && std::env::var("MOTOR_RNR_MODELL").is_ok_and(|x| x == "pool");
|
||||
let gegen = pool && std::env::var("MOTOR_RNR_GEGEN").is_ok_and(|x| x == "1");
|
||||
let rnr_turn = pool && std::env::var("MOTOR_RNR_TURN").is_ok_and(|x| x == "1");
|
||||
strasse == 3 && !offen && (rnr || std::env::var("MOTOR_NL2LOCK").is_ok_and(|x| x == "1"))
|
||||
|| pool && (strasse == 3 || strasse == 2 && rnr_turn) && (!offen || gegen)
|
||||
}
|
||||
|
||||
pub fn vertrauen_p(q: &Value) -> f64 {
|
||||
q["p"].as_f64().filter(|x| x.is_finite()).map_or(1.0, |x| x.clamp(0.0, 1.0))
|
||||
}
|
||||
|
||||
@@ -28,6 +28,14 @@
|
||||
//! und die Tabelle spielt sofort; jede Frage hat eine Frist (MOTOR_SHARINGAN_FRIST_MS, Standard 1000), danach spielt die
|
||||
//! Tabelle bzw. gilt die eigene Range, und der Dienst wird 5 s lang nicht gefragt. Start ohne Prioritaetsflag (erbt Normal vom
|
||||
//! Motor mit hoher Prioritaet), HYBRID_FAEDEN aus MOTOR_SHARINGAN_FAEDEN.
|
||||
//! - MOTOR_SUCHE_QUELLE=sharingan (29.11. spaet, Standard aus, nur mit dem Hybrid): auf Turn und River, und auf dem Flop dort,
|
||||
//! wo sonst sein Blueprint spielt, antwortet SHARINGANs Echtzeit-Suche (eigener Dienst mit HYBRID_SUCHE=1, feste Iterationszahl
|
||||
//! MOTOR_SUCHE_ITERS statt Uhr (ohne: Standard des Dienstes, 24000), MOTOR_SUCHE_FAEDEN Faeden, Port MOTOR_SUCHE_ADRESSE Standard 127.0.0.1:47127, Exe MOTOR_SUCHE_EXE).
|
||||
//! Frist je Frage: frist_rest_s der Anfrage, hoechstens MOTOR_SUCHE_DECKEL (2,5 s), minus MOTOR_SUCHE_PUFFER (0,3 s). Kommt
|
||||
//! keine echte Suche (source "search") in der Frist (nicht bereit, Blueprint statt Suche, Frist gerissen): Turn/River rechnet
|
||||
//! der Motor wie bisher (seine eigene Frist zaehlt ab Ankunft weiter), der Flop spielt den Blueprint wie bisher. Nie fuer
|
||||
//! Vorrechnen-Scheiben. Bekannte Luecke: die Suche ist rakefrei.
|
||||
//! MOTOR_SUCHE_QUELLE=sharingan_ausser_rnr: dasselbe, aber wo unsere RNR-/NL2-Sperre greift, spielt unser Motor.
|
||||
use serde_json::{json, Value};
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
@@ -434,7 +442,11 @@ fn frage_roh(v: &Value) -> Option<Value> {
|
||||
/// Der eigene Zug von SHARINGAN, als Vertragsantwort. None: er weiss keinen (dann spielt der Motor).
|
||||
pub fn zug(q: &Value, k: &Kontext) -> Option<Value> {
|
||||
let r = frage(&json!({"op": "act", "req": k.basis}))?;
|
||||
let o = &r["response"];
|
||||
abbilden(q, &r["response"], String::new())
|
||||
}
|
||||
|
||||
/// Seine Antwort (`response`) als Vertragsantwort zum Zustand `q`; `zusatz` haengt an den Grund.
|
||||
fn abbilden(q: &Value, o: &Value, zusatz: String) -> Option<Value> {
|
||||
let a = &o["action"];
|
||||
let bb = q["bigBlind"].as_f64()?;
|
||||
let f = |x: &str| q[x].as_f64();
|
||||
@@ -462,7 +474,120 @@ pub fn zug(q: &Value, k: &Kontext) -> Option<Value> {
|
||||
groesse = None;
|
||||
}
|
||||
Some(json!({"action": akt, "size": groesse, "confidence": 1,
|
||||
"reason": format!("sharingan {} ({})", o["source"].as_str().unwrap_or("?"), o["street"].as_str().unwrap_or("?"))}))
|
||||
"reason": format!("sharingan {} ({}){zusatz}", o["source"].as_str().unwrap_or("?"), o["street"].as_str().unwrap_or("?"))}))
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ MOTOR_SUCHE_QUELLE=sharingan (Echtzeit-Suche)
|
||||
|
||||
pub fn suche_an() -> bool {
|
||||
static A: OnceLock<bool> = OnceLock::new();
|
||||
*A.get_or_init(|| an() && (schalter("MOTOR_SUCHE_QUELLE", "sharingan") || suche_ausser_rnr()))
|
||||
}
|
||||
/// MOTOR_SUCHE_QUELLE=sharingan_ausser_rnr: wie sharingan, aber wo unsere RNR-/NL2-Sperre greift (River, Turn mit MOTOR_RNR_TURN,
|
||||
/// gegen Einsatz mit MOTOR_RNR_GEGEN, p aus vertrauen), spielt unser Motor (dienst::rnr_sperre_greift).
|
||||
pub fn suche_ausser_rnr() -> bool {
|
||||
static A: OnceLock<bool> = OnceLock::new();
|
||||
*A.get_or_init(|| an() && schalter("MOTOR_SUCHE_QUELLE", "sharingan_ausser_rnr"))
|
||||
}
|
||||
/// Protokollzeile ohne Zeit (fuer "suche-rnr": die Suche wurde wegen der RNR-Sperre nicht gefragt).
|
||||
pub fn protokoll_marke(op: &str) {
|
||||
protokoll(op, Instant::now(), true);
|
||||
}
|
||||
fn suche_zahl(k: &str, d: f64) -> f64 {
|
||||
std::env::var(k).ok().and_then(|x| x.parse().ok()).unwrap_or(d)
|
||||
}
|
||||
fn such_adresse() -> String {
|
||||
std::env::var("MOTOR_SUCHE_ADRESSE").unwrap_or_else(|_| "127.0.0.1:47127".into())
|
||||
}
|
||||
|
||||
/// Den Suchdienst starten (wie starte_dienst, eigener Port, HYBRID_SUCHE=1), hoechstens alle 30 s.
|
||||
fn starte_suchdienst() {
|
||||
static ZULETZT: Mutex<Option<Instant>> = Mutex::new(None);
|
||||
let mut g = ZULETZT.lock().unwrap_or_else(|e| e.into_inner());
|
||||
if g.is_some_and(|t| t.elapsed().as_secs() < 30) {
|
||||
return;
|
||||
}
|
||||
*g = Some(Instant::now());
|
||||
const F: &str = "D:/pokerfreak-fremd/sharingan";
|
||||
let exe = std::env::var("MOTOR_SUCHE_EXE").unwrap_or_else(|_| format!("{F}/code/target/serve/pokerbench-hybrid-suche.exe"));
|
||||
let args = std::env::var("MOTOR_SHARINGAN_ARGS")
|
||||
.unwrap_or_else(|_| format!("--blueprint {F}/weights/B-local-2e10.plcp --buckets {F}/data/buckets-200 --sizing local"));
|
||||
let mut c = std::process::Command::new(exe);
|
||||
c.args(args.split_whitespace()).stdin(std::process::Stdio::null()).stdout(std::process::Stdio::null()).stderr(std::process::Stdio::null());
|
||||
if let Some(port) = such_adresse().rsplit(':').next() {
|
||||
c.args(["--port", port]);
|
||||
}
|
||||
c.env("HYBRID_SUCHE", "1");
|
||||
if phm() {
|
||||
c.env("HYBRID_UEBERSETZUNG", "phm");
|
||||
}
|
||||
for (von, nach) in [("MOTOR_SUCHE_ITERS", "HYBRID_SUCHE_ITERS"), ("MOTOR_SUCHE_FAEDEN", "HYBRID_SUCHE_FAEDEN")] {
|
||||
if let Ok(x) = std::env::var(von) {
|
||||
c.env(nach, x);
|
||||
}
|
||||
}
|
||||
#[cfg(windows)]
|
||||
{
|
||||
use std::os::windows::process::CommandExt;
|
||||
let prio = if live() { 0 } else { 0x4000 };
|
||||
c.creation_flags(0x8 | 0x0800_0000 | prio | 0x0100_0000);
|
||||
if c.spawn().is_err() {
|
||||
c.creation_flags(0x8 | 0x0800_0000 | prio);
|
||||
let _ = c.spawn();
|
||||
}
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
let _ = c.spawn();
|
||||
}
|
||||
|
||||
/// Eine Frage an den Suchdienst: eigene Verbindung je Frage (eine verspaetete Antwort landet nie in der naechsten Frage),
|
||||
/// Lesefrist `frist`. None: nicht erreichbar, nicht bereit, Frist gerissen.
|
||||
fn such_frage(v: &Value, frist: Duration) -> Option<Value> {
|
||||
let a: std::net::SocketAddr = such_adresse().parse().ok()?;
|
||||
let s = match TcpStream::connect_timeout(&a, Duration::from_millis(100)) {
|
||||
Ok(s) => s,
|
||||
Err(_) => {
|
||||
starte_suchdienst();
|
||||
return None;
|
||||
}
|
||||
};
|
||||
s.set_nodelay(true).ok()?;
|
||||
s.set_read_timeout(Some(frist.max(Duration::from_millis(1)))).ok()?;
|
||||
let mut w = s.try_clone().ok()?;
|
||||
writeln!(w, "{v}").ok()?;
|
||||
w.flush().ok()?;
|
||||
let mut z = String::new();
|
||||
BufReader::new(s).read_line(&mut z).ok().filter(|&n| n > 0)?;
|
||||
serde_json::from_str::<Value>(&z).ok().filter(|r| r["ok"] == true)
|
||||
}
|
||||
|
||||
/// Der Zug aus SHARINGANs Suche (Turn/River, Flop wo sein Blueprint spielt). None: keine echte Suche in der Frist.
|
||||
pub fn such_zug(q: &Value, k: &Kontext) -> Option<Value> {
|
||||
if !suche_an() || q["vorrechnen_strasse"] == true {
|
||||
return None;
|
||||
}
|
||||
let t0 = Instant::now();
|
||||
let deckel = suche_zahl("MOTOR_SUCHE_DECKEL", 2.5);
|
||||
let rest = q["frist_rest_s"].as_f64().map_or(deckel, |r| r.min(deckel)) - suche_zahl("MOTOR_SUCHE_PUFFER", 0.3);
|
||||
if rest < 0.2 {
|
||||
protokoll("suche-zu-knapp", t0, false);
|
||||
return None;
|
||||
}
|
||||
let frist = Duration::from_secs_f64(rest);
|
||||
// seine harte Frist etwas spaeter als unsere: sein kooperativer Deckel (0,7 x Frist) kuerzt die Suche erst, wenn wir sie
|
||||
// ohnehin nicht mehr nehmen; was wir nehmen, hat die volle feste Iterationszahl
|
||||
let sein_ms = (rest * 1000.0 / 0.7) as u64 + 100;
|
||||
let r = such_frage(&json!({"op": "suche", "req": k.basis, "budget_ms": sein_ms}), frist);
|
||||
let o = r.as_ref().map(|r| &r["response"]);
|
||||
let echt = o.is_some_and(|o| o["source"] == "search");
|
||||
// Protokoll: bei Rueckfall mit seiner Quelle (blueprint = Suche nicht moeglich, z. B. Fremdgroesse; fallback; keine = nicht bereit/Frist)
|
||||
let quelle = o.map_or("keine".to_string(), |o| format!("{}:{}", o["source"].as_str().unwrap_or("?"), o["reason"].as_str().unwrap_or("-")));
|
||||
protokoll(if echt { "suche".to_string() } else { format!("suche-rueckfall:{quelle}") }.as_str(), t0, echt);
|
||||
if !echt {
|
||||
return None;
|
||||
}
|
||||
let ms = o.and_then(|o| o["timing"]["search_ms"].as_f64()).unwrap_or(0.0);
|
||||
abbilden(q, o?, format!(" {ms:.0} ms"))
|
||||
}
|
||||
|
||||
type Vektor = Arc<Vec<f32>>;
|
||||
|
||||
Reference in New Issue
Block a user