dpv007 commited on
Commit
ca046f7
·
verified ·
1 Parent(s): a1ce99a

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. neural_engine/src/main.rs +16 -2
neural_engine/src/main.rs CHANGED
@@ -224,10 +224,24 @@ fn main() {
224
  }
225
  }
226
  "go" => {
 
 
 
 
 
 
 
 
227
  if let Some(ref mut sess) = session {
228
  let mut root = MCTSNode::new(1.0);
229
- // 1000 simulations for deeper tactical evaluation (aiming for ~2400 Elo)
230
- for _ in 0..1000 {
 
 
 
 
 
 
231
  mcts_simulate(&mut root, board.clone(), &mut history_moves, sess, &vocab, &inv_vocab);
232
  }
233
 
 
224
  }
225
  }
226
  "go" => {
227
+ let mut movetime_ms = 5000;
228
+ if tokens.contains(&"movetime") {
229
+ let idx = tokens.iter().position(|&r| r == "movetime").unwrap();
230
+ if let Ok(t) = tokens[idx + 1].parse::<u128>() {
231
+ movetime_ms = t;
232
+ }
233
+ }
234
+
235
  if let Some(ref mut sess) = session {
236
  let mut root = MCTSNode::new(1.0);
237
+ let start_time = std::time::Instant::now();
238
+ // Leave a small buffer (5% or minimum 50ms) to ensure we reply in time
239
+ let buffer = (movetime_ms as f64 * 0.05) as u128;
240
+ let safe_movetime = if movetime_ms > buffer { movetime_ms - buffer } else { movetime_ms };
241
+ let limit = std::time::Duration::from_millis(safe_movetime as u64);
242
+
243
+ // Loop continuously until time expires
244
+ while start_time.elapsed() < limit {
245
  mcts_simulate(&mut root, board.clone(), &mut history_moves, sess, &vocab, &inv_vocab);
246
  }
247