Wishes in Genshin Impact

Using a Markov chain to model the Genshin Impact's gacha system. Find out the probabilities, expected number of wishes, and cost of each character in human currency!

The story of this post starts from the following video I watched and saw how Michael joked about spending 5 million USD to get a particular legendary character 7 times. He later said it was around 2000 USD.

I was fascinated to calculate what the actual numbers might be for this game - probabilities, expected number of wishes and actual cost of each character. I had to comment on this video.

I wanted to work through the math of this game and also highlight the different psychological weaknesses that humans have which are being brilliantly exploited by miHoYo to make us spend and play more. It is both scary and eerily worthy of respect how good these products are getting.

The Game

So you likely have not heard of this game before and don't know what wishes mean. Let me bring you upto speed regarding all the jargon I'll be using in this post.

This game - Genshin Impact is mainly a single player game with some co-op elements (cooperative play with upto 3 other friends). It is free to download and play but most of the characters and the best weapons are only accessible through "wishes".

You basically spend in game currency to buy this lottery ticket called a wish and you gamble on the hope you get the character you want. This in game currency is quite rare and people end up wanting to spend real money to buy more wishes.

Now don't get me wrong there is a lot of other content you can do as a player who refuses to spend any money (f2p or free to play). You have recipes to cook different food that can boost your attack, defense, recover health, revive fallen characters.

It has all the elements of a fantasy ARPG (action role playing game) - you have real time combat, it is not the slow turn based combat. You can forge weapons, craft potions and other materials that you use to enhance weapons and characters. You have lots of place to explore, find chests, climb mountains in this beautiful open world.

Sword pools are often found in Chinese novels.
Sadly I could not take an in game picture while gliding

You can interact with the enviroment much like BotW (Breath of the Wild), where fire burns the grass. You can freeze the water in lakes and oceans to walk on it. You can jump off mountains and glide around. So that should give you an idea of what the game has to offer and why it has been so popular since launch.

Look the numbers are crazy, they reportedly made 60 million USD after the first week of launch. This is just from the Apple store and Google Play store.

Who knows how much they made via other platforms? They supposedly fired a guy who once leaked numbers. They are a private company and won't reveal it. From what we know, they spent 100 million USD to make this game and made it back in the first two weeks.

The music was not cheaply done, I can attest to the quality of voice acting for English and Japanese. They support 13 text language and 4 fully voiced languages (Japanese, Chinese, Korean, and English). The game also has great cross-play, which means you can seamlessly switch devices ( Windows, PlayStation 4, Android, iOS, Nintendo Switch ) without losing any progress. All progress is continously saved to miHoYo servers.

To help you get an idea of how large an amount 100 million USD is, consider the widely popular game Apex Legends's launch. In the game’s first month of release, Apex Legends reportedly made over $90 million from in-game spending across all platforms.

Anyway you can read in depth coverage of these stuff, in this reddit post. This post is also great if you want to know what many players hate about the game in its current state. They have this resin system which restricts how fast you can progress in the game so they have time to make more content. It also prevents whales (players who spend a lot of money on the game) from just maxing out all the characters, losing interest and moving on to other games. miHoYo wants you hooked for the long term.

Enough about the game, let us understand how the wishes are implemented.


So what happens when you cast a wish? You have to choose which banner you cast the wish under. The standard banner which is called "Wanderlust Invocation" is of a permanent duration but other banners are available only for short period of time (making use of FOMO to manipulate you into spending money) and give boosted probabilities to characters.

I would not recommend this banner since pulling a 5 star weapon would reset your pity.

Like the "Ballad in Goblets" banner that ran from 28th Sep to 18th Oct. Which boosted the chances (by comparison) for Venti, Barbara, Fischl and Xiangling.

Venti will never be available in the permanent banner. Using limited time to affect consumer decision making has now become quite common. :(

To understand the rules let us start with the permanent banner and see what the probabilities look like,

The pity mechanism depends on past pulls. This game can be modelled by Markov Chains.

Well, when you cast a wish under Wanderlust then with a probability of 0.943 you get some shit 3 star item. With a probability of 0.051 you get a 4 star item or character. Finally with a probability of 0.006 you get a 5 star character or weapon.

Visually each wish is like a single chance to pick a random cell among these 1000 cells. 5 star is green, 4 star is purple and a 3 star trash weapon is red. Remember you can craft and get 4 star weapons in game without spending money.

The light green represents the 5 5-star characters while the dark green is for the 10 5-star weapons. The light purple represents the 14 4-star characters while the dark purple is for the remaining 18 4-star weapons.

But now comes this pity mechanism that improves your chances. If you were "unlucky" not to get any 4 star or 5 star item in 9 rolls then you get one on the 10th roll. Similarly 89 rolls without a 5 star means the 90th roll is a guaranteed 5 star. I do not think it is especially unlucky since most people will hit both pity most of the time. The probabilities for hitting pity are $(1-0.057)^9 = 0.589$ and $(1-0.006)^{89} = 0.5853$.

This pity system might seem like it was made for us players, but there is a hidden agenda here. Knowing that we are sure to get a 5 star character people will spend on crystals to wish the remaining number of times and hit pity. Especially when the banner is of limited time you don't have the luxury to slowly collect the primogems in game to make the 90 wishes you need to hit pity.

Talk in terms of Money!

Ok so how much does it cost in real world money? A single wish on any banner costs 160 primogems to buy. You cannot buy primogems directly, you can buy "genesis crystals" which are one way redeemable to primogems. You can also buy some starter packs with crystals but that is generally considered to be poor use of crystals.

Start of Retraction

So since I never actually bought any of the packs, I did not know that after this one time bonus of double the gems. There is a permanent bonus that scales with the pack size.

Kind redditor u/osoichan corrected me. So I am gonna redo my calculations now. Below is the old analysis I did.

Depending on the pack you use, a single rupee can get you anywhere from 0.759, 0.751, 0.817, 0.861, 0.820, 0.820 crystals.

The crazy thing is, the 2300 Rs pack is the most value for money pack. I see whales just buying the last pack assuming it is the most value for money but if you spend 2400 USD on 24 100 USD packs (like what the guy maxing out venti did or what most whales seem to do) then you are getting $6480 \times 24 = 155,520$ Genesis Crystals.

But if you spent that on the 1980 pack costing 30 USD, then you get $1980\times \frac{2400}{30} = 158,400$ Genesis Crystals. That is $2880$ crystals or 18 wishes more!

In INR terms, if you buy $x$ packs of 6480 crystals, you could have bought $\frac{7900x}{2299} = 3.43x$ packs of 1980 crystals.

$$=\frac{7900x \times 1980}{2299} -  6480x$$

$$ = 6803.82x - 6480x = 323.4x$$

So you lost $323.4x$ crystals. In the above case of 24 packs you get 7761 crystals if you are an Indian Genshin Impact player. That is 48.5 wishes! Indians pay way more for these crystals, note how 100 USD is only 7,353 INR.

Unless they change the cost, Always buy the 1980 crystal pack. Except for the first time bonuses of course.

Now visually it is clear how these packs look different at low amounts of money. Both the one time bonus and the fact most people buy packs one at a time mean that they fall for a suboptimal option.

The red line is the 60 pack, blue is the 300 pack, green is 980, purple is 1980, black is 3280 and orange is 6480. The dotted green line is the Blessing of the Welkin Moon but that is capped at 3000 per month.

It is clear how much of a great deal the 400₹ monthly card seems by comparison. But remember they can set the price however they want. By setting the distance between the two options to be this large they break down the defense of many players and make them start spending on the game.

This tactic they use is making use of a known cognitive bias of humans called anchoring in psychology.

It is quite deceptive how they let us assume the higher value packs are more value for money. These tactics make it clear that the company is clearly focused on making money and preying on the players and less on providing the player with a valuable experience.

All whales buy each pack once to get the one time bonus. After that within the next 3000 or so Rs spent you see a difference of one wish emerge

Since we are talking about big spenders here let us consider only the 1980 pack and say 160 crystals or 1 wish costs $\frac{160 \times 2299}{1980} = 185.77₹$

End of Retraction

So the actual pack looks like this,

long term pack
Depending on the pack you use, a single rupee can get you anywhere from 0.759, 0.827, 0.909, 0.974, 0.970, 1.022 crystals.

So one wish costs $\frac{160\times 7900}{6480+1600} = 156.43₹$

So I was off by less than $30₹$.

Markov Chain Modelling

I am auditing E1 246 this semester. So I naturally thought it would be fun to use a small result that was brought up during one of the introductory classes to answer some questions people who spend large amounts of money on this might have.

The result talks about if we build a transition matrix based on one step probabilities then the $k$th powers of that matrix will give you the $k$th step probability.

To understand let us take a simple case of modelling a frog that jumps between two leaves on a pond. When it is on leaf A it feels uncomfortable and 80% of the time it jumps to leaf B. But it does not like leaf B that much either and 70% it jumps back to A.

Credits to Victor Powell : You can see how the $2 \times 2$ transition matrix looks like for this markov chain

The $0,0$ element of the matrix tells you the probability of a A to A transition in one time step, so with $0.2$ probability the frog sitting in leaf A won't move. The $0,1$ element tells you the probability of a A to B transition in one time step, which is $1-0.2 = 0.8$.

The $1,0$ element tells you the probability of a B to A transition in one time step which is $0.3$. The $1,1$ element, $0.7$ is the probability that it decided to stay in leaf B itself. So a one step B to B transition.

Now if this is the transition matrix $T$, consider what $T^2$ looks like,

$$T^2 = \left [ \begin{matrix} 0.2 & 0.8 \\ 0.3 & 0.7 \\ \end{matrix} \right ] \left [ \begin{matrix} 0.2 & 0.8 \\ 0.3 & 0.7 \\ \end{matrix} \right ] $$

$$= \left [ \begin{matrix}  0.2 \times 0.2+ 0.8 \times 0.3 &  0.2 \times 0.8 +   0.8 \times 0.7\\ 0.3 \times 0.2 +   0.7 \times 0.3 & 0.3 \times 0.8 +   0.7 \times 0.7 \\ \end{matrix} \right ] $$

Note how the $0,0$ element of the matrix now tells you the probability of going from A to A in two time steps! There are two ways this A to A can happen in two steps.

$$A \xrightarrow{0.2} A \xrightarrow{0.2} A$$

$$A \xrightarrow{0.8} B \xrightarrow{0.3}A$$

So since both transitions are independent we can multiply the probabilties. Since there is no intersection between these two events we can add these two probabilities to get the final probability $ 0.2 \times 0.2+ 0.8 \times 0.3 = 0.28$ that the frog will go start from leaf A and return back in two steps.

Try to work this out for the other transitions and also calculate $T^3$ and understand how this works for any $k$th step. You should try to never accept mathematical facts, you need to practice until it becomes intuition.

Ok so once we are on the same page that the $i,j$th element of the matrix $T^k$ gives you the probability of going from state $i$ to state $j$ in $k$ steps. We just need to construct the $T$ matrix for each banner and define the states carefully.

Wanderlust Invocation

So I am going to define the states $C_{i,j}$ as having gotten the particular $5$ star character we want $i$ times in the past, it is the $j$th wish since we got the $5$ star character or weapon. Since we are interested in maxing out this particular $5$ star character so $i$ runs from $0$ to $6$ and since pity hits after 90 wishes $j$ runs from $1$ to $90$.

If we get the character multiple times, it allows us to unlock the character's "constellations" which basically make the character stronger. You have a total of $6$ constellations for each character.

The $C$ state's with varying $j$ index keep track of how long we are stuck waiting for $5$ star pity to hit us. We don't care about $4$ star pity and this model cannot tell us anything about how often we get 4 star characters. The $i$ index keeps track of how many constellations we have gotten of character $X$.

Let $B_{i}$ be the state of getting a $5$ star character or weapon that is not $X$ in this particular wish while having gotten the particular $5$ star character - $X$ we want $i$ times in the past. This $i$ runs from $0$ to $6$ since we stop traversing this chain once we hit $A_6$ and get the 7th constellation.

Let $A_{i}$ be the state of having gotten the particular 5 star character - $X$ we want $i$ times in the past, we happen to get that $5$ star character $X$ in this particular wish.  This $i$ runs from $0$ to $6$.

So now the markov chain is complete. We know that we start from the $C_{0,1}$ state and wish to know the probability of reaching different $A$ states within $k$ wishes or steps.

So there will be another 86 C states where I kept the dotted lines, but this should give you an idea about how the transition between these states look like.

To build the transition matrix we just need to fill in $3$ values in every row corresponding to the C states of the $644\times 644$ matrix. We get that size by adding the states corresponding to $A$, $B$ and $C$ respectively. $7+7+90\times 7 = 644$

This is because there are only $3$ paths out of states $C_{i,j}$. We can go to $A_{i}$, $B_{i}$ or $C_{i,j+1}$ with probabilities $0.0004$, $0.006-0.0004 = 0.0056$ and $1-0.006 = 0.994$ respectively. Here $i$ runs from $0$ to $6$ and $j$ runs from $1$ to $90$.

Actual probability of getting any particular character X is $\frac{0.006}{15} = 0.0004$

That takes care of $89\times 7 = 630$ rows, what about the $C_{i,90}$ state? this means you hit pity and this wish takes you directly to a 5 star state so either $A_i$ with probability $0.0\bar6$ or to $B_i$ with probability $0.9\bar 3$.

We should also create a self loop at the end state we are interested in, say $A_6$ if we want to know how many wishes are needed to max this particular constellation.

Now I wrote the code to construct the transition matrix $M$ and used numpy.linalg to perform the large powers of the matrix.

import numpy as np
import matplotlib.pyplot as plt
from functools import reduce
from numpy.linalg import matrix_power

N = 5000
pulls = []
prob = []

# Build the transition matrix of size 7+7+907 = 644644
M = np.zeros((644,644))

# states 0*90 = 0 	 to 1*90-1  = 89  are C01 to C090, 
# states 1*90 = 90   to 2*90-1  = 179 are C11 to C190,
# states 2*90 = 180  to 3*90-1  = 269 are C21 to C290, 
# states 3*90 = 270  to 4*90-1  = 359 are C31 to C390,
# states 4*90 = 360  to 5*90-1  = 449 are C41 to C490, 
# states 5*90 = 450  to 6*90-1  = 539 are C51 to C590,
# states 6*90 = 540  to 7*90-1  = 629 are C61 to C690,
# states 630         to 630+7-1 = 636 are B0 to B6
# states 637         to 637+7-1 = 643 are A0 to A6

# There are only 3 paths out of states Cij; to Ai, Bi or Ci(j+1) for j in 1 to 89, 
# the 90th consecutive NON 5 star pull will take you to a 5 star state, either A or B
A = 0.0004 # 1/15 of 0.6%
B = 0.0056 # 14/15 of 0.6%
C = 0.994 # 1 - 0.6%

for i in range(7):
	for j in range(i*90,(i+1)*90-1):
		# j is the state index in the matrix
		M[j][630+i] = B # you get some other 5 star
		M[j][637+i] = A # you get character X
		M[j][j+1] = C # you get no 5 star this pull

	# The Archon of Wishes have taken pity on you, the 90th wish or Ci90 state has only 2 paths.
	M[(i+1)*90-1][630+i] = 0.93333 # 14/15
	M[(i+1)*90-1][637+i] = 0.06666 # 1/15

	# some other 5 star character, but gotta reset pity i.e. Bi takes you to Ci1
	M[630+i][i*90] = 1
	# you are lucky! you got character X so move from Ai to C(i+1)1 but A6 is the last state so except for that
	if(i != 6):
		M[637+i][(i+1)*90] = 1

# You stop playing when you hit A7 - character X has been maxed out
M[643][643] = 1

#remove connection from A0 to C11
M[637][90] = 0
# let A0 become the end state
M[637][637] = 1

k = 1

# The probability of moving from state C01 to A7 in k steps is M^k[0][636]
	temp = matrix_power(M,k)[0][637] # A0 getting once
	k += 1

		print("Probability of getting character X in "+str(k)+" pulls is "+str(temp))

fig = plt.figure()
plt.bar(pulls, prob)
fig.suptitle('Genshin Impact', fontsize=20)
plt.xlabel('Number of wishes', fontsize=18)
plt.ylabel('Probability', fontsize=16)

Let us look at the results of running this code as bar graphs.

How many wishes before we have a good chance of getting character X at full strength?
10,000 wishes or 15,64,356.43₹ to have a 83% probability of getting maxed out character X. 12,500 for a 95% probability.

But let us be realistic here, we don't dream of actually getting maxing out any particular character in the short term. Especially with free to play gamers getting just 1,800 primogems (11 wishes per month) via dalies.

How many wishes before we get that particular 5 star character for the first time on this permanent banner?
This looks much more promising, 2000 wishes and 85.2%, 3500 for 96.8%. Interestingly only the first 3 pities seem to show a significant jump.

If someone has an intuitive explanation for why the jump in probabilites decrease with consecutive pities please do comment below. I observed 0.03 to 0.07 at 90 then 0.124 to 0.146 at 180, 0.203 to 0.215 at 270, 0.273 to 0.279 at 360 etc.

Anyway, since most of the content - 3d model, voice, abilities are unlocked the first time you get the character. I'd say each 5 star character on this banner can be valued at 1000 to 3000 wishes or 1,56,435₹ to 4,69,306₹.

Yeah sounds bad. This is why you should avoid the permanent banner like the plague. Always wait for a temporary banner to come which has the probabilities for that character you like boosted.

Let us assume you want one of the boosted characters, say klee who is boosted in the banner Sparkling Steps. Let us change the probabilities in the code and run and see how much money we save by waiting for the temporary banner with similar probabilties.

It is really not fair to compare getting Klee to getting a particular 5 star from the main banner since Klee is not one of the characters on the main banner. But in the future when they have a Diluc or Keqing banner I assume the probabilties to be the same.

Sparkling Steps

So now we have to add an additional state to keep track of this one time pity.

I have heard some people claim that the 180 wish pity for the 5 star character klee is not just for the first time you get her but also counts when you try to get the constellations. But the paragraph is quite clear and starts with the words - "The first time you...".

By adding the 180 pity the probabilities are much better,

58% chance of getting klee in 100 pulls

89 wishes to 90 wishes gives you a probability jump from $0.256$ to $0.55$. Before you hit the $180$ pity you already have a $0.82$ probability getting Klee.

Still I value Klee, or promotional 5 star characters at 180 wishes or 28,158.4₹.

How many wishes to get 5 of her constellations unlocked?
850 wishes and 61% chance, 1250 wishes and 94.5% chance.

But here you can visually compare with the permanent banner and the steeper slope is clear. The better probabilities mean that you should try to always wait for the banner to come.

Even if we ignore pity and make a similar colored graph for this banner. The benefit of there being no 5 star weapons ($10 \to 0$) is clear. You will also get the one of the 3 featured characters within the first 20 wishes.  

The dark green here are the other 5 star characters. The light and dark purple are the 4-star characters and weapons respectively.

I might later try to answer more questions like, How many rolls before we get atleast one of each 5 star character?  That will be an obscenely large number of wishes. How many rolls before we get atleast one of each 4 star character? That might give a reasonable number.


I did not expect to write so much but I had a lot of fun building the markov chain for this game. I think the main takeaway is that we should be aware of exactly what we are getting when we spend money on gems. This game is basically an online version of gambling and is therefore not playable in Belgium where they have sane laws.

I expect many people to get addicted to this game and ruin their lives. This is a great read about one such person. I also hope this post showed you one way that matrices are useful. Maths helps us answer questions that we face daily.