Spaces:
Sleeping
Sleeping
| """ | |
| Time Manager for Nexus-Nano | |
| Ultra-simple time control for fast games | |
| """ | |
| import time | |
| class TimeManager: | |
| """Minimal time management""" | |
| def __init__(self): | |
| self.start_time = 0.0 | |
| self.allocated_time = 0.0 | |
| self.hard_limit = 0.0 | |
| def start_search(self, allocated_time: float, hard_limit: float): | |
| self.start_time = time.time() | |
| self.allocated_time = allocated_time | |
| self.hard_limit = hard_limit | |
| def should_stop(self, depth: int) -> bool: | |
| """Simple time check""" | |
| elapsed = time.time() - self.start_time | |
| # Hard limit | |
| if elapsed >= self.hard_limit: | |
| return True | |
| # Soft limit for depth >= 3 | |
| if elapsed >= self.allocated_time and depth >= 3: | |
| return True | |
| return False | |
| def elapsed(self) -> float: | |
| return time.time() - self.start_time |