I was send here from stackoverflow because they thought maybe you can help me.
Here my original post: https://stackoverflow.com/questions/26799476/a-faster-way-then-doing-14-for-loops
What I want:
Maybe someone knows the Smartphone game "Elemental Kingdoms" If not i will try to explain.
You got a whole bunch of cards and runes. And you choose 10 cards and 4 runes. This is then your deck.
The enemy got a Demon (a very strong card which you have to damage as hard as possible).
Know you draw every time its your turn a card. A Card got Cooldown ( time until it can be played which reduces every round) if it has has cooldown 0 it can be played. Its automaticly placed on the first free place on your field.
Cards can attack cards in front of them. although everycard got abilitys which are giving them aditional attack or resistance or stuns....
Its over if the demon is dead (doesnt matter for the simulation) or when the player got no cards left or is health is 0. Health is lost if no card is in front of the demon that could take the damage or if the demon got a ability through that health is lost.
Know i wanted to create a Simulator which creates every deck, simulates the fight serveral times and at the end gives out the Deck which dealt the most damage to the demon.
The Problem with that is: There are more than 200 cards which can be used (and the same card could be 10 times in the deck) so there are to many possible decks.
So i wondered if someone knows if it is possible to do what i want mathematically or should i just leave it?
I appreciate everything that helps me :)
It sounds like you have far too many choices to list all the possible decks. In cases like that one usually resorts to generating random decks as a sample of all possible decks. It sounds like you are drawing your deck with replacement. If there are $200$ cards, you throw $10$ random numbers from $1$ through $200$ and those are the cards in your deck. Pick your four runes the same way. Run your simulation with this deck. Do this lots of times, keeping track of the best results.
Now you can just accept the best deck you found. It will probably not be the best possible, but it shouldn't be bad. Another approach is to print out the best few dozen decks found with their scores and look at them. You may find some regularities there. For example, there might be some particular card that is in every one, because it is particularly strong. You can then go back and redo the simulation with that card always picked first. You could also collect statistics over the cards. For each card, you might compute the average score of all the decks it is in. Some strong or weak ones may stand out. If you run a lot of trials, you could even compute average scores for decks with a given pair of cards. Since there are tens thousands of pairs, you would need millions of simulations, but if they are fast that is OK.
Basically you are using your simulator as a research tool. You collect data, study it, make a hypothesis about what makes a strong deck, and test that hypothesis. Have fun. It is a good way to learn programming.