private void AddChoiceOfStepGraph(LtmdpStepGraph stepGraph, int continuationId, long locationForContinuationGraphElement) { BufferCidMapping(continuationId, locationForContinuationGraphElement); var choice = stepGraph.GetChoiceOfCid(continuationId); if (choice.IsChoiceTypeUnsplitOrFinal) { AddFinalChoiceOfStepGraph(choice.To, locationForContinuationGraphElement, choice.Probability); return; } if (choice.IsChoiceTypeForward) { // no recursive descent here var bufferedTargetCid = GetBufferedLtmdpCid(choice.To); _ltmdp._continuationGraph[locationForContinuationGraphElement] = new ContinuationGraphElement { ChoiceType = choice.ChoiceType, From = bufferedTargetCid, To = bufferedTargetCid, Probability = choice.Probability }; return; } var offsetTo = choice.To - choice.From; var numberOfChildren = offsetTo + 1; var placesForChildren = _ltmdp.GetPlaceForNewContinuationGraphElements(numberOfChildren); _ltmdp._continuationGraph[locationForContinuationGraphElement] = new ContinuationGraphElement { ChoiceType = choice.ChoiceType, From = placesForChildren, To = placesForChildren + offsetTo, Probability = choice.Probability }; for (var currentChildNo = 0; currentChildNo < numberOfChildren; currentChildNo++) { var originalContinuationId = choice.From + currentChildNo; var newLocation = placesForChildren + currentChildNo; AddChoiceOfStepGraph(stepGraph, originalContinuationId, newLocation); } }