dpv007 commited on
Commit
83375cb
·
verified ·
1 Parent(s): 4b30b2a

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. neural_engine/src/main.rs +27 -0
neural_engine/src/main.rs CHANGED
@@ -812,6 +812,7 @@ fn main() {
812
  // Dynamic Time Management Loop
813
  let mut last_best_move = String::new();
814
  let mut move_stability = 0;
 
815
  loop {
816
  std::thread::sleep(std::time::Duration::from_millis(50));
817
  let elapsed = start_time.elapsed().as_millis();
@@ -860,6 +861,32 @@ fn main() {
860
  break;
861
  }
862
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
863
  }
864
  }
865
 
 
812
  // Dynamic Time Management Loop
813
  let mut last_best_move = String::new();
814
  let mut move_stability = 0;
815
+ let mut last_print_time = std::time::Instant::now();
816
  loop {
817
  std::thread::sleep(std::time::Duration::from_millis(50));
818
  let elapsed = start_time.elapsed().as_millis();
 
861
  break;
862
  }
863
  }
864
+
865
+ // Stream UCI info periodically so GUIs and Lichess can read eval/nodes in real time!
866
+ if last_print_time.elapsed().as_millis() > 500 {
867
+ last_print_time = std::time::Instant::now();
868
+ let mut root_visits = 0;
869
+ let mut current_best_val = 0.0;
870
+ if let Some(root_ref) = arena.get(&global_root_hash) {
871
+ let root = root_ref.lock().unwrap();
872
+ root_visits = root.visit_count;
873
+ if let Some(&child_hash) = root.children.get(&best_action) {
874
+ if let Some(child_ref) = arena.get(&child_hash) {
875
+ let child = child_ref.lock().unwrap();
876
+ if child.visit_count > 0 {
877
+ current_best_val = child.value_sum / child.visit_count as f32;
878
+ }
879
+ }
880
+ }
881
+ }
882
+ let score_cp = (current_best_val * 1000.0) as i32;
883
+ let pv = extract_pv(global_root_hash, &arena);
884
+ let mut pv_str = String::new();
885
+ for m in pv { pv_str.push_str(&format!("{} ", m)); }
886
+ let nps = if elapsed > 1000 { (root_visits as u128 * 1000) / elapsed } else { 0 };
887
+ let depth = (root_visits as f64).log2().max(1.0) as i32 + 5; // MCTS heuristic depth
888
+ println!("info depth {} score cp {} nodes {} nps {} time {} pv {}", depth, score_cp, root_visits, nps, elapsed, pv_str);
889
+ }
890
  }
891
  }
892