private List <RandomOutcome> GenerateRandomOutcomes(State initialState, Ability action) { double successProbability = Compute.SuccessRate(action.BaseSuccessRate, initialState); State successState = action.Activate(initialState, true); State failureState = action.Activate(initialState, false); List <RandomOutcome> entries = new List <RandomOutcome>(); entries.Add(new RandomOutcome(successProbability, successState, Condition.Normal, true)); if (failureState != null) { entries.Add(new RandomOutcome(1.0 - successProbability, failureState, Condition.Normal, false)); } return(entries); }
private void AdvancePlayback() { Simulator.Engine.Ability optimalAction = analyzer.OptimalAction(currentState); RadioParams selectedParams = (RadioParams)selectedRadio.Tag; string statusString = (selectedParams.success) ? "Success" : "Failure"; string conditionString = selectedParams.condition.ConditionString(); currentState = optimalAction.Activate(currentState, selectedParams.success); currentState.Condition = selectedParams.condition; if (currentState.Status == SynthesisStatus.IN_PROGRESS) { if (!analyzer.TryGetOptimalAction(currentState, out optimalAction)) { // We hit a leaf. Kick off a new analysis. SetAppState(AppState.Analyzing); worker.RunWorkerAsync(currentState); } else { UpdateUIStateForPlayback(currentState, optimalAction); } } else { UpdateUIStateForPlayback(currentState, null); } }