public IActionMemoryQuartet FindBestActionMemoryQuartet(Point position) { Position = position; // Look around at special position RaiseExperienceWanted(); ISensationSnapshot sensationSnapshotBeforeAction = _lastSensationSnapshot; IActionMemoryQuartet bestActionMemoryQuartet = GetBestActionMemoryQuartet(position, sensationSnapshotBeforeAction); return(bestActionMemoryQuartet); }
private void Timer_Tick(object sender, EventArgs e) { _timer.Enabled = false; if (_playMode.Equals(PlayMode.FindBest)) { var bestAction = _robotBrain.FindBestActionMemoryQuartet(_scanPosition); Console.WriteLine($" {_scanPosition} \t--> bestAction: {bestAction}"); if (_bestActionMemoryQuartet == null || _bestActionMemoryQuartet.StepSize < bestAction.StepSize) { _bestActionMemoryQuartet = bestAction; _bestPosition = _scanPosition; } _scanPosition = GetNextScanPoint(_scanPosition, _puzzleBoard.Size); if (_scanPosition.Equals(Point.Empty)) { _robotBrain.Position = _bestPosition; _cbxDirectionTypes.SelectedItem = _bestActionMemoryQuartet.Action.Direction; _cbxFindBest.Checked = false; Console.WriteLine($"Best found for position:\t{_bestPosition} \taction:{_bestActionMemoryQuartet}"); } } else { if (_simulationRunsInBackground) { _nudRemainigIterationCount.Value = _backgroundIterations; _tbrSolvingPercentage.Value = (int)_robotBrain.PercentageSolving; RefreshPlayGround(); RecreateCells(); } else { bool resetOnError = _cbxBehaviourOnError.SelectedIndex == 2; if (_cbxBehaviourOnError.SelectedIndex == 3) { resetOnError = _tbrSolvingPercentage.Value <= 50; } RunOneIteration(resetOnError); _nudRemainigIterationCount.Value -= 1; if (_nudRemainigIterationCount.Value <= _nudRemainigIterationCount.Minimum) { _cbxRunInterations.Checked = false; } } } _timer.Enabled = CheckIfTimerShouldBeActive(); }