private void HandleAdditionalRewards(GameWithProbability currentGame, Boxes boxes, List <AdditionalReward> additionalRewards) { foreach (var additionalReward in additionalRewards) { var game = new GameWithProbability(currentGame); game.Add(new AdditionalRewardMove(additionalReward, new Fraction(1, additionalRewards.Count))); if (additionalReward == AdditionalReward.SecondChance) { var newAdditionalRewards = new List <AdditionalReward>(additionalRewards); newAdditionalRewards.Remove(additionalReward); Generate(game, boxes, newAdditionalRewards); } else { _games.Add(game); } } }
private void Generate(GameWithProbability currentGame, Boxes boxes, List <AdditionalReward> additionalRewards) { foreach (var box in boxes) { var game = new GameWithProbability(currentGame); var moveProbability = new Fraction(box.Count, boxes.CountBoxes()); game.Add(new RewardMove(box.Reward, moveProbability)); var newBoxes = new Boxes(boxes); newBoxes.RemoveBox(box.Reward); if (box.Reward == Reward.GameOver && !HasExtraLife(game.Moves)) { HandleAdditionalRewards(game, newBoxes, additionalRewards); continue; } Generate(game, newBoxes, additionalRewards); } }