Genshin Impact: Sucrose vs. Dori, Mathematically

by greenturtle3141, Aug 5, 2023, 10:16 PM

Reading Difficulty: 2-3/5
Prerequisites: Some knowledge of some parts of combinatorics and probability will be helpful.

Here's a short and sweet one for now, but stay tuned for a longer piece soonish. No knowledge of Genshin Impact is required.

In Genshin, there is a very simplistic "crafting" system. Different characters give different bonuses when crafting. Two such characters are Sucrose and Dori.

https://cdn.aops.com/images/d/d/a/dda1e4e8f154de14c05799fe4b23131deb4b24c5.png

Here is the setup, in alternative terms: Suppose you start with $n$ "tokens". Sucrose and Dori are two different people that can exchange your tokens for money.
  • When you give Sucrose $3$ tokens, she will give you a dollar. Then, there is a $10\%$ chance that she gives you a second dollar.
  • When you give Dori $3$ tokens, she will give you a dollar. Then, there is a $25\%$ chance that she gives you back $1$ token.
Naturally, your goal is to make as much money as possible. Who should you exchange your tokens with? (For simplicity, let's assume you pick exactly one person to exchange tokens with, i.e. you don't exchange with both of them in some order, which a priori could be wise for small values of $n$.)

I invite you to think about this! It's not a crazy hard problem (at least, compared to some of the other stuff I talk about on this blog...), and it can be a good exercise for C&P in math competitions. Read on for the solution.


So it turns out that... (Answer)

Let's do the math now.

Analysis of Sucrose

This is the easy part. If you choose tokens, then you don't get any tokens back, so you'll make exactly $\lfloor n/3\rfloor$ exchanges. In expectation, a tenth of these exchanges will grant an extra dollar, so the expected number of dollars you can get from Sucrose is $(1+1/10)\lfloor n/3 \rfloor = \boxed{\frac{11}{10}\left\lfloor\frac n3\right\rfloor}$.

As $n \to +\infty$, this is asymptotically equivalent to the fraction $\frac{11}{30}n$.

Analysis of Dori: Heuristics

Here, we'll make a reasonable guess as to what the answer should be approximately by playing fast and loose with our logic.

If we start with $n$ tokens, then at the start we can make around $n/3$ exchanges to get $n/3$ dollars. Then, we get about a quarter of this number in tokens back, i.e. we get around $n/12$ tokens returned. Now, we can make around $n/36$ exchanges to get $n/36$ dollars, and we'll get $n/144$ tokens back. The pattern is clear: If we keep doing this "forever", then the expected value seems to be like a geometric series:
$$\frac{n}{3} + \frac{n}{36} + \frac{n}{144 \cdot 3} + \ldots$$The ratio between terms is $\frac1{12}$, so this sums to $\frac{n/3}{1-1/12} = \frac{4n}{11}$. This is our guess for the asymptotic ratio as $n \to +\infty$. And, note how close this is to Sucrose's ratio! $11/30$ is veerryyyyy close to $4/11$ --- if we cross multiply by $30 \times 11$, the difference is $121$ vs. $120$.

The reason why this is a "guess" is because we assumed a lot of uniformity. For example, we assumed that we'd get exactly $n/3$ tokens back, which is a reasonable guess but not representative of reality because it's only the expected value, so carrying the value of $n/3$ forward is not necessarily going to work.

Analysis of Dori: Exact Value

Let's try to glean a formula for the exact expected value of dollars you get from Dori as a function of $n$. Let this expected value be $f(n)$.

Since your number of tokens can change, it is natural to try and set up a recurrence. Let's start with $n$ tokens, and spend $3$ of those tokens. There are two possibilities:
  • With $3/4$ chance, Dori only gives you a dollar, so your expected value in this case is $1 + f(n-3)$.
  • With $1/4$ chance, Dori gives you a dollar and increments your number of tokens by $1$, so your expected value in this case is $1 + f(n-2)$.
It follows that:
$$f(n) = 1 + \frac34f(n-3) + \frac14f(n-2)$$This is the recurrence we need!

It's always good to compute some of the first few terms of $f(n)$ to make sure that we're on the right track. We can manually find that $f(0) = f(1) = f(2) = 0$ and $f(3) = f(4) = 1$, and indeed this is consistent with our recurrence.

We now need to turn the recurrence into a nice formula. Unfortunately it's not going to be nice. First, for $n \geq 4$ we can stack two copies of the recurrence on top of each other:
$$f(n) = 1 + \frac34f(n-3) + \frac14f(n-2)$$$$f(n-1) = 1 + \frac34f(n-4) + \frac14f(n-3)$$Then we subtract them to obtain:
$$f(n) = f(n-1) + \frac14 f(n-2) + \frac12 f(n-3) - \frac34 f(n-4)$$(Sanity check: The sum of coefficients on each side is equal, so I didn't mess up.) What this process does is eliminate the $1$.

Now, the characteristic polynomial for this recurrence is given by
$$x^4 - x^3 - \frac14x^2-\frac12x+\frac34.$$Without any calculation we know that $x=1$ must be a root (why?) and that this must factor as
$$(x-1)\left(x^3-\frac14x-\frac34\right).$$We see that $x=1$ is a root of the cubic (why is this not surprising?), and so this factors further as
$$(x-1)^2(x^2+x+3/4).$$By the quadratic formula, we see that the roots of the characteristic polynomial are $1$ (a double root) and $\frac{-1}{2} \pm \frac{i}{\sqrt{2}}$.

By the theorem that relates recurrences to the roots of their characteristic polynomial, it follows that the closed form for $f(n)$ is
$$f(n) = A \cdot 1^n + B n \cdot 1^n + C\left(\frac{-1}{2} + \frac{i}{\sqrt{2}}\right)^n + D\left(\frac{-1}{2} - \frac{i}{\sqrt{2}}\right)^n$$for constants $A,B,C,D$. (The $Bn$ term is there because of the double root.)

Fortunately, we have quite a few obvious starting values of $f$ that we can use! Plugging in $n=0,1,2,3$ gives the following system:
$$\begin{cases}A + C + D = 0 \\ A + B + \left(\frac{-1}{2} + \frac{i}{\sqrt{2}}\right)C + \left(\frac{-1}{2} - \frac{i}{\sqrt{2}}\right)D = 0 \\
A+2B + \left(\frac{-1}{2} + \frac{i}{\sqrt{2}}\right)^2C + \left(\frac{-1}{2} - \frac{i}{\sqrt{2}}\right)^2D = 0 \\ A+3B + \left(\frac{-1}{2} + \frac{i}{\sqrt{2}}\right)^3C + \left(\frac{-1}{2} - \frac{i}{\sqrt{2}}\right)^3D = 1\end{cases}$$Of course, no sane person would or should be solving this by hand, so I plugged this into Wolfram Alpha and got the following solution:
$$A = \frac{-48}{121}, B = \frac4{11}, C = \frac{24}{121} - \frac{14\sqrt{2}}{121}i, D = \frac{24}{121} + \frac{14\sqrt{2}}{121}i$$Thus our closed form, and the expected value of dollars we get from $n$ tokens, is:
$$\boxed{\frac{4}{11}n - \frac{48}{121} + 2\text{Re}\left[\left(\frac{24}{121} - \frac{14\sqrt{2}}{121}i\right)\left(\frac{-1}{2} + \frac{i}{\sqrt{2}}\right)^n\right]}$$(I combined both complex parts since they happened to be conjugates... to the surprise of not many people.)

What is the consequence of this formula? Well, note that $\left|\frac{-1}{2} + \frac{i}{\sqrt{2}}\right| < 1$, so that whole real-part/complex term will tend to $0$ rapidly as $n \to +\infty$. In other words, the oscillatory part of the formula is not significant at all in the long run. And, the term $\frac{48}{121}$ is just a constant, so although this constant will prevail as $n \to \infty$, it's not asymptotically significant when compared to the linear growth of the term $\frac{4}{11}n$. So in the long run, the expected value will asymptotically look like $\frac{4}{11}n$ --- just as we had claimed in the heuristics!

Comment

1 Comment

The post below has been deleted. Click to close.
This post has been deleted. Click here to see post.
Interesting that mihoyo balanced them that much

by pog, May 20, 2024, 5:12 PM

Turtle math!

avatar

greenturtle3141
Archives
+ October 2024
Shouts
Submit
  • Can you give some thought to dropping a guide to STS? Just like how you presented your research (in your paper), what your essays were about, etc. Also cool blog!

    by Shreyasharma, Mar 13, 2025, 7:03 PM

  • this is so good

    by purpledonutdragon, Mar 4, 2025, 2:05 PM

  • orz usamts grader

    by Lhaj3, Jan 23, 2025, 7:43 PM

  • Entertaining blog

    by eduD_looC, Dec 31, 2024, 8:57 PM

  • wow really cool stuff

    by kingu, Dec 4, 2024, 1:02 AM

  • Although I had a decent college essay, this isn't really my specialty so I don't really have anything useful to say that isn't already available online.

    by greenturtle3141, Nov 3, 2024, 7:25 PM

  • Could you also make a blog post about college essay writing :skull:

    by Shreyasharma, Nov 2, 2024, 9:04 PM

  • what gold

    by peace09, Oct 15, 2024, 3:39 PM

  • oh lmao, i was confused because of the title initially. thanks! great read

    by OlympusHero, Jul 20, 2024, 5:00 AM

  • It should be under August 2023

    by greenturtle3141, Jul 11, 2024, 11:44 PM

  • does this blog still have the post about your math journey? for some reason i can't find it

    by OlympusHero, Jul 10, 2024, 5:41 PM

  • imagine not tortoise math

    no but seriously really interesting blog

    by fruitmonster97, Apr 2, 2024, 12:39 AM

  • W blog man

    by s12d34, Jan 24, 2024, 11:37 PM

  • very nice blog greenturtle it is very descriptive and fascinating to pay attention to :-D

    by StarLex1, Jan 3, 2024, 3:12 PM

  • orz blog

    by ryanbear, Dec 6, 2023, 9:23 PM

67 shouts
Tags
About Owner
  • Posts: 3553
  • Joined: Oct 14, 2014
Blog Stats
  • Blog created: Oct 23, 2021
  • Total entries: 54
  • Total visits: 40923
  • Total comments: 126
Search Blog
a