# How to determine the round of a game given it's state number?

Let's say I've made a game where it's possible to mark a total of 15 categories as either used or unused, and have a game score that's anything in the range of 0 and 39 (both inclusive, and ignoring that marking a category leads to a certain minimum score). The total number of game states is therefore 2^15 *40. Marking a category is associated with a round in the game, so after marking your 4th category (any of the currently unmarked ones are available) you're in the 4th round. Determining the number of states in any round i is done using some combinatorics:

$g_{i}=\frac{15!}{(15-i)!(i!)}$

If I summarize all states in each round in sequential order, then it must be possible to say that the j'th state is in round r. Is there a formula to determine, given a state number, which round the state belongs to?

• use factoring or modulo, it should hold round k iff $0 = j \mod 2^k$ or $0 = j \mod k$ it is hard to understand the state and round from the question excatly but in any case they should be exact multiples of one the other Jun 15, 2014 at 19:41
• the deternination of $j$ is lacking, is this just an index on the state at round $k$ or is it related in another way? In the first case it is not possible to relate $j$ to $k$ since multiple $k$'s have same $j$'s In the other case an exact factoring or counting may work Jun 15, 2014 at 19:53

No, this is a difficult problem, basically you need to evaluate the break-off points for each round (the last number of state pertaining to each round). Notice the break of point of round $n$ is $\sum_{k=0}^n\binom{15}{k}$. This number is really hard to compute and has no closed form.
$$\begin{matrix} 1&16\\ 2&121\\ 3&576\\ 4&1941\\ 5&4944\\ 6&9949\\ 7&16384\\ 8&22819\\ 9&27824\\ 10&30827\\ 11&32192\\ 12&32647\\ 13&32752\\ 14&32767\\ 15&32678\\ \end{matrix}$$