EDIT Given the amount of time spent on the problem I eventually solved it, so below I leave the structure of the original problem and the answer I came up with. I will be writing it up over the next few days, as I want to explain it clearly and share for opinions, if you have any.
Hello mathematical community.
I picked up a deck building game (HEX TCG) and set out to find out the inner workings of resource management without more than the bare bones of and engineer's knowledge of statistics. I came to my solution after a week and below is the explanation of the problem and how I attacked it applying principles of probabilities, please enjoy and share your views.
Please take note that I may use terminologies in a slightly personal way as that is my relationship with statistical maths, though I am making my best effort to describe it with the correct terms.
Intro:
A deck is constituted by 60 cards. There are several types of cards but for this problem we only need focus on 2 types of cards, type 1: resource cards and, type 2: non-resource cards. Resources are needed to play cards.
How the cards are played:
On the opening turn of the game the player draws 7 cards from the deck into their hand.
- Which player goes first is decided by a coin flip. The player that goes second only is allowed to draw an extra card on the opening turn.
During each turn (including the opening turn) the player is allowed to play only 1 resource from their hand, if they possess one. Once played it stays on the field.
At the beginning of each new turn each player draws 1 card from the remaining deck.
The problem:
The objective of a player building their deck is to build it with enough resources to give them the best chance of playing a minimum number of resources to the field as fast as possible. This minimum number of resources the player should aim to play as fast as possible is dictated by the highest costing cards in the player's deck (cards can cost up to 7 resources).
It is obvious that if you had 100% resources this would maximise the probabilities but then the player wouldn't be able to do anything so the objective is to draw up a relationship to calculate the optimal number and its associated probability of being playable.
For the sake of keeping the problem simple I analysed the maths and the effect on the initial 10 turns, read ahead.
The Stats
The first part of the problem consisted in describing the probability of drawing a specific number of resources into the players hands in the opening turn based on whether the player draws 7 or 8 or whether the player Mulligans (decides to redraw their hand, but in doing so draw 1 card less).
Drawing The First Hand
I first of all calculated how many permutation (without repetitions) the probability tree yields for each drawn amount of cards using equation:
$$\frac{n!}{r!\,(n-r)!} \tag{1}\label{1}$$
where
$n=$Total drawn cards ($1\leq n\leq8$)
$r=$Total drawn resource cards ($0\leq r\leq7$)
This yields the amount of different combinations in which a given number of $r$ can be drawn into the players hand below is the case for $r=7$:
Resources drawn (r) 0 1 2 3 4 5 6 7
No. of permutations 1 7 21 35 35 21 7 1
This is to be multiplied by the probability of drawing that number of resource cards into the players hand which I worked out as the following equation:
$$\left(\frac{\frac{T_{R}!}{(T_{R}-r)!}\times\frac{T_{N}!}{(T_{N}-(n-r))!}}{\frac{T!}{(T-n)!}}\right) \tag{2}\label{2}$$
Where (as above $n=$Total drawn cards and $r=$Drawn resources) and:
$T_{R}=$Total resources in initial deck.
$T_{N}=$ Total non-resources in initial deck.
$T=$Total initial deck cards.
It follows that that $T_{R}+T_{N}=T=60$.
Below is the calculated example for the case$T_{R}=23$ and $r=3$ resources drawn for $n=7$ cards drawn into hand.
$$\left(\frac{\frac{23!}{(23-3)!}\times\frac{37!}{(37-(7-3))!}}{\frac{60!}{(60-7)!}}\right)=\left(\frac{(23\cdot22\cdot21)\times(37\cdot36\cdot35\cdot34)}{60\cdot59\cdot58\cdot57\cdot56\cdot55\cdot54}\right)=0.008653\dots$$
The final probability, which I will call $P(n,r)$, for any given value of $n$ and $r$, is simply equation $\eqref{1}\times$ equation $\eqref{2}$ as follows:
$$\left(\frac{n!}{r!\,(n-r)!}\right)\times\left(\frac{\frac{T_{R}!}{(T_{R}-r)!}\times\frac{T_{N}!}{(T_{N}-(n-r))!}}{\frac{T!}{(T-n)!}}\right)=P(n,r) \tag{3}\label{3}$$
So once again for the above case where $T_{R}=23$
$$P(n=7,r=3)=0.008653\dots\times35=30.29\%$$
I could hence at this point graph the probability curves for all values of drawn resources $r$ (when drawing $n=7$ cards for the below image) for all values of possible $T_{R}$ resources in the deck:
Resources in a deck vs probability of drawing $r$ resources into an $n=7$ hand
Drawing Each Turn
The next step involved the same maths but applied to the situation of drawing resources with each turn. This yields a second probability tree and a formula identical to equation $\eqref{1}$ to calculate the amount of permutations (again without repetition) for the amount of resources drawn and turns played:
$$\left(\frac{n_{2}!}{r_{2}!\,(n_{2}-r_{2})!}\right) \tag{4}\label{4}$$
Where:
$n_{2}=$Number of turns after drawing turn.
$r_{2}=$Number of resources drawn in the turns $n_{2}$.
The second part for the formula to describe this situation is the same as equation $\eqref{2}$ but this time with the $r_{2}$ and $n_{2}$ terms added to the factorials as follows:
$$\left(\frac{\frac{(T_{R}-r)!}{(T_{R}-r-r_{2})!}\times\frac{(T_{N}-(n-r))!}{(T_{N}-(n-r)-(n_{2}-r_{2}))!}}{\frac{(T-n)!}{(T-n-n_{2})!}}\right) \tag{5}\label{5}$$
Where (as above $n_{2}=$Number of turns and $r_{2}=$Drawn resources in those turns) and:
$T_{R}=$Total resources in initial deck.
$T_{N}=$ Total non-resources in initial deck.
$T=$Total initial deck cards.
Once again multiply the number of permutations based on $r_{2}$ (equation $\eqref{4}$ by equation $\eqref{5}$:
$$\left(\frac{n_{2}!}{r_{2}!\,(n_{2}-r_{2})!}\right)\times\left(\frac{\frac{(T_{R}-r)!}{(T_{R}-r-r_{2})!}\times\frac{(T_{N}-(n-r))!}{(T_{N}-(n-r)-(n_{2}-r_{2}))!}}{\frac{(T-n)!}{(T-n-n_{2})!}}\right)=P(n_{2},r_{2}) \tag{6}\label{6}$$
to get probability $P(n_{2},r_{2})$. The graph of which looks as below:
Resources in deck vs the probability of drawing $r_{2}=5$ resources in $n_{2}=10$ turns given the amount of resourced already drawn into hand in the opening phase ($n=1$)
Intercept Probability
Now if we take equation $\eqref{3}$ as being equal to $P(A)$ and $\eqref{6}$ as being equal to $P(B|A)$ then:
$$P(A\cap B)=P(A)\times P(B|A)$$
Meaning:
$$P(A\cap B)=\left(\frac{n!}{r!\,(n-r)!}\right)\times\left(\frac{\frac{T_{R}!}{(T_{R}-r)!}\times\frac{T_{N}!}{(T_{N}-(n-r))!}}{\frac{T!}{(T-n)!}}\right)\times\left(\frac{n_{2}!}{r_{2}!\,(n_{2}-r_{2})!}\right)\times\left(\frac{\frac{(T_{R}-r)!}{(T_{R}-r-r_{2})!}\times\frac{(T_{N}-(n-r))!}{(T_{N}-(n-r)-(n_{2}-r_{2}))!}}{\frac{(T-n)!}{(T-n-n_{2})!}}\right) \tag{7}\label{7}$$
Which finally gives the probability of drawing $r_{2}$ resource cards over a period of $n_{2}$ turns, based on the probability of having drawn $r$ resources into a hand of size $n$!
For the same case as shown just above of $P(B|A)$ where $n_{2}=10$ and $r_{2}=5$, the $P(A\cap B)$ gives the following graph:
Resources in a deck vs the probability of drawing $r_{2}=5$ resources within $n_{2}=10$ turns given the player has drawn $r$ resources in an opening hand of size $n=7$
Limits of the Equations
It is important at this point to note the limits within which these equations don't break. The cases which return non-computable values are associated to factorials of negative numbers. These arise in the following cases and corresponding IF statements should be included as advised:
For equation $\eqref{3}$:
IF $T_{N}<(n-r)$ is TRUE then set $\left(\frac{T_{N}!}{(T_{N}-(n-r))!}\right)=0$ otherwise it would be an invalid number.
IF $(T_{R}-r)<0$ is TRUE then set $\left(\frac{T_{R}!}{(T_{R}-r)!}\right)=0$ otherwise it will be an invalid number.
For equation $\eqref{6}$:
IF $(T_{N}-(n-r))<(n_{2}-r_{2})$ is TRUE then set $\left(\frac{(T_{N}-(n-r))!}{(T_{N}-(n-r)-(n_{2}-r_{2})!}\right)=0$ otherwise it will be an invalid number.
IF $(T_{R}-r-r_{2})<0$ is TRUE then set $\left(\frac{(T_{R}-r)!}{(T_{R}-r-r_{2})!}\right)=0$ otherwise it will be an invalid number.
Conclusion
So above I have described the formulation of the equations associated with being able to solve the issue associated with resource optimisation in a deck, now how do we apply it to give us a usable number?
Check out the answer.
Given that ultimately the final equation:
$$P(A\cap B)=\left(\frac{n!}{r!\,(n-r)!}\right)\times\left(\frac{\frac{T_{R}!}{(T_{R}-r)!}\times\frac{T_{N}!}{(T_{N}-(n-r))!}}{\frac{T!}{(T-n)!}}\right)\times\left(\frac{n_{2}!}{r_{2}!\,(n_{2}-r_{2})!}\right)\times\left(\frac{\frac{(T_{R}-r)!}{(T_{R}-r-r_{2})!}\times\frac{(T_{N}-(n-r))!}{(T_{N}-(n-r)-(n_{2}-r_{2}))!}}{\frac{(T-n)!}{(T-n-n_{2})!}}\right)$$
Is dependent on many variables:
$T$ Total cards in a deck.
$T_{R}$ Total resources in a deck and hence also $T_{N}$ Total non-resources in a deck.
$n$ number of cards drawn into hand in the opening turn and $r$, how many are resources.
$r_{2}$ Number of resources drawn in the successive $n_{2}$ turns.
It is important to approach the problem in a manner that makes sense with respect to the result the equation gives. The above probability equation is to be plotted out for all $T_{R}$ and $r$ values leaving $n$, $n_{2}$ and $r_{2}$ as the variable parameters.
The Problem
The objective was to obtain the optimal number of resources for a deck based on how many resources a player wants/needs to have the best chances of drawing within the initial turns. So if consider a player that wants to draw 5 resources within the first 5 turns there are several cases that can yield this result.
Its Solving
Assuming the player has drawn 7 cards ($n$), the different combinations that give him 5 within the first 5 turns are the different ways of summing $r$ and $r_{2}$ to total 5; so the player could draw 1 card in hand ($r$) and then in the next 4 ($n_{2}$) turns draw 4 more cards ($r_{2}$), or 2 in hand and 3 drawn.
So it is important to compute $r_{2}$ for all situations between the values of $0\leq r_{2}\leq n_{2}$ up to $n_{2}=$Desired amount of resources to be played.
Once these are computed the answer to how many resources does my deck require is easily extracted from the computations: by looking at the case for $r=0$ and $r_{2}=5$ ($n_{2}=5$ too) it is a matter of finding the highest probability for the pair of values over the range of $T_{R}$ total resources in a deck.
The value of $T_{R}$ found for the $r=0$ case will be the same as that for the value of $r=1$, however it will have a different probability associated with it.
For the above case the value is $T_{R}=25$
The Probability
The probability associated with drawing that many resources in those turns with the optimal number of them in the deck is simply obtained by the sum of probabilities associated with all pairs of $r+r_{2}=n_{2}$ which for the case above where $n_{2}=5$ it is 25%.
Closing Remark
The formula isn't perfect as it considers in effect the desired number of turns (in which to play your minimum desired amount of resources) +1 turn linked to the case where the player draws no resources in hand. So in effect the number of cards is correct, but the probability is more associated with $n_{2+1\,turn}$.
I hope you enjoyed the post and feel free to contribute and ask a few questions I will do my best to answer.