void _controller_CurrentPeriodChangedEvent(ITimeControl control) { if (InvokeRequired) { WinFormsHelper.BeginFilteredManagedInvoke(this, UpdateUI); } else { UpdateUI(); } }
/// <summary> /// Instantiates a new instance of the EngineThreadManager. /// </summary> /// <param name="openingBook">Opening book to use. Can be null if no opening book is to be used.</param> /// <param name="searchEvaluator">Search tree with evaluator to use for moves not pressent in the opening book.</param> /// <param name="timeControl">Time controller responsible for calculating search times.</param> public EngineManager(IOpeningBook openingBook, ISearchTree searchEvaluator, ITimeControl timeControl) { m_openingBook = openingBook; m_searchTree = searchEvaluator; m_timeControl = timeControl; m_waitHandle = new ManualResetEvent(true); m_workerThread = new BackgroundWorker(); m_workerThread.DoWork += FindMove; m_workerThread.RunWorkerCompleted += FindMoveCompleted; }
public BatchingWriter(ICrispinClient client, int batchSize = 5, ITimeControl time = null, TimeSpan interval = default(TimeSpan)) { time = time ?? new RealTimeControl(); interval = interval != TimeSpan.Zero ? interval : TimeSpan.FromSeconds(5); _client = client; _batchSize = batchSize; _pending = new ConcurrentQueue <Statistic>(); _cancel = time.Every(interval, Send); }
public PeriodicFetcherTests() { _toggles = Enumerable.Range(0, 5).Select(i => new Toggle { ID = Guid.NewGuid(), Name = i.ToString() }).ToArray(); _client = Substitute.For <ICrispinClient>(); _timeControl = Substitute.For <ITimeControl>(); _timeControl .Delay(Arg.Any <TimeSpan>(), Arg.Any <CancellationToken>()) .Returns(Task.CompletedTask); }
protected void Step(float steps) { ITimeControl control = _control; if (control == null) { return; } // TODO: for a better precision, remember the leftovers in steps, and pass them on next go. if (control.StepForward((int)steps) == false) { timerStep.Enabled = false; UpdateUIEnables(); } }
/// <summary> /// Instantiates a new instance of the chess facade. /// </summary> public ChessFacade() { m_openingBook = new OpeningBook(); m_evaluator = new BoardEvaluator(); m_searchTree = new SearchTree(m_evaluator); m_timeControl = new TimeControl(); m_engineManager = new EngineManager(m_openingBook, m_searchTree, m_timeControl); m_engineManager.MoveFound += EngineMoveFound; m_engineConfiguration = new EngineConfiguration(true, true, new TimeSpan(0, 1, 0), 25); m_clockConfiguration = new ClockConfiguration(ClockType.Conventional, 40, new TimeSpan(0, 25, 0), new TimeSpan(0, 15, 0), new TimeSpan(0, 0, 10)); m_currentGame = new Game(null, m_clockConfiguration); m_currentGame.WhiteClockNotifier += WhiteClockEventHandler; m_currentGame.BlackClockNotifier += BlackClockEventHandler; m_boardCopy = new Board(m_currentGame.Board); m_previousGames = new Stack <Game>(); m_subsequentGames = new Stack <Game>(); }
public PeriodicFetcher(ICrispinClient client, TimeSpan frequency, ITimeControl timeControl = null) { timeControl = timeControl ?? new RealTimeControl(); _toggles = new Dictionary <Guid, Toggle>(); _source = new CancellationTokenSource(); _initialLoadDone = new TaskCompletionSource <bool>(); _backgroundFetch = Task.Run(async() => { await SafeReadToggles(client); _initialLoadDone.SetResult(true); while (_source.IsCancellationRequested == false) { await timeControl.Delay(frequency, _source.Token); await SafeReadToggles(client); } }, _source.Token); }
/// <summary> /// Instantiates a new instance of the chess facade. /// </summary> public ChessFacade() { m_openingBook = new OpeningBook(); m_evaluator = new BoardEvaluator(); m_searchTree = new SearchTree(m_evaluator); m_timeControl = new TimeControl(); m_engineManager = new EngineManager(m_openingBook, m_searchTree, m_timeControl); m_engineManager.MoveFound += EngineMoveFound; m_engineConfiguration = new EngineConfiguration(true, true, new TimeSpan(0, 1, 0), 25); m_clockConfiguration = new ClockConfiguration(ClockType.Conventional, 40, new TimeSpan(0, 25, 0), new TimeSpan(0, 15, 0), new TimeSpan(0, 0, 10)); m_currentGame = new Game(null, m_clockConfiguration); m_currentGame.WhiteClockNotifier += WhiteClockEventHandler; m_currentGame.BlackClockNotifier += BlackClockEventHandler; m_boardCopy = new Board(m_currentGame.Board); m_previousGames = new Stack<Game>(); m_subsequentGames = new Stack<Game>(); }
public void Initialize(ITimeControl timeControl) { this.m_timeControl = timeControl; }
public static ScriptPlayable <TimeControlPlayable> Create(PlayableGraph graph, ITimeControl timeControl) { ScriptPlayable <TimeControlPlayable> result; if (timeControl == null) { result = ScriptPlayable <TimeControlPlayable> .get_Null(); } else { ScriptPlayable <TimeControlPlayable> scriptPlayable = ScriptPlayable <TimeControlPlayable> .Create(graph, 0); scriptPlayable.GetBehaviour().Initialize(timeControl); result = scriptPlayable; } return(result); }
public virtual bool AddSlaveControl(ITimeControl control) { lock (_slaveControls) { return(_slaveControls.Add(control)); } }
public virtual bool RemoveSlaveControl(ITimeControl control) { lock (_slaveControls) { return _slaveControls.Remove(control); } }
public virtual bool AddSlaveControl(ITimeControl control) { lock (_slaveControls) { return _slaveControls.Add(control); } }
/// <summary> /// /// </summary> public TimeManagementSkipToControl(ITimeControl timeControl) { InitializeComponent(); _timeControl = timeControl; }
public virtual bool RemoveSlaveControl(ITimeControl control) { lock (_slaveControls) { return(_slaveControls.Remove(control)); } }
/// <summary> /// Creates a Playable with a TimeControlPlayable behaviour attached /// </summary> /// <param name="graph">The PlayableGraph to inject the Playable into.</param> /// <param name="timeControl"></param> /// <returns></returns> public static ScriptPlayable <TimeControlPlayable> Create(PlayableGraph graph, ITimeControl timeControl) { if (timeControl == null) { return(ScriptPlayable <TimeControlPlayable> .Null); } var handle = ScriptPlayable <TimeControlPlayable> .Create(graph); handle.GetBehaviour().Initialize(timeControl); return(handle); }