Variation with variable count of possibilities <p>I have programmed a game where the player has 30 days to build city. I like to know all the possible approaches the player could take so that i know which is the best one.</p> <p>Basicly with 30 days and 9 projects which can be bought and upgraded the mathematical formula would be n^k. Which in our case woud be 9^30 = 42.391.158.275.216.203.514.294.433.201 But because it is a game the projects the player can buy per round depend on variabels like for examples coins. So its something like 4*1*5*3*2...</p> <p>My problem is that GameStats, which simulates the game environment, does not get reset when a new buildpath is added.</p> <p>Example</p> <p>The player starts with 15 coins and an income of 5. First day he build houses for 10 coins</p> <ul> <li>day 0: buildpath{house}; coins 15 -> bought house -10 coins</li> <li>day 1: buildpath{house, empty}; coins 5 -> no coins to buy anything</li> <li>day 2: buildpath{house, empty, house}; coins 10 -> player can buy house, street or cycletrack</li> </ul> <p>now for the next possible buildpath we start at day 2 where could also have bougth the street or the cycletrack and had 10 coins but GameStats which holds the coins is now by 15coins.</p> <p>How do I keep the GameStats unique for every possible buildpath?</p> <pre><code>public string[] GetPermutation(int days, List&lt;BaseProject&gt; projects) { ArrayList output = new ArrayList(); GameStats game = new GameStats(); GetPermutationPerRef(days, projects, ref output, ref game); return output.ToArray(typeof(string)) as string[]; } private void GetPermutationPerRef(int days, List&lt;BaseProject&gt; projects, ref ArrayList output, ref GameStats game, string outputPart = "") { if (days == 0) { outputPart += " points: " ; output.Add(outputPart); } else { if(projects.Count &gt; 0) { foreach (BaseProject p in projects) { // construct the current project game.BuyProject(p); // move on to the next day game.nextDay(); // find all the projects the player could buy the next day projects = game.GetBuyAbleBaseProjects(); GetPermutationPerRef(days - 1, projects, ref output, ref game, outputPart + p.projectName +" "); } } else { // dont buy or upgrade any project game.nextDay(); projects = game.GetBuyAbleBaseProjects(); GetPermutationPerRef(days - 1, projects, ref output, ref game, outputPart + "empty "); } } } </code></pre>