A simple game code analysis on Balatro

Summary

  1. From Ante 11 onwards, the difficulty of the joker increases significantly.
  2. The endless mode is truly infinite, and you can't really "beat the game".

Opportunity

I often find myself putting together a deck that isn't too good, but after reaching a certain ante level, the difficulty of the game increases dramatically. The score for beating the blinds becomes so big that the game feels unbeatable.


So, I was curious about how the game calculates blind scores. After extracting the Lua file from the game package, using the keyword "300" (the initial blind amount), I found  theget_blind_amount (ante) in misc_functions.lua.

Foundfound


Here's the full details:

This method is easy to analyze:There are three if statements that set the initial amount for each round based on different ante_scaling parameters, where 1 is the lowest and 3 is the highest.

For example, in the game.lua file, we will see that the plasma deck is set to 2.

The remaining code is the same for each IF statement, and the score (amount) is set according to the blind level (ANTE). When the blinds are less than 1, the score is 100. When the blinds are 8 or less, the score is taken from the list of counts.

The code then uses the blind rating and score table to set parameters a, b, c, d to calculate the blind amount when the blinds are greater than 8.

As the blind level n approaches infinity, since c and d are linear functions of n, A actually moves beyond the exponential growth we know and into the realm of iterative power. This is a very interesting mathematical concept, so I won't go into too much detail here.

when Ante level = 8:

When looking at the curve, it was found that the endless mode had a smoother curve and a "manageable" blind score at an ante rating of 1 to 8.Ante level = 9, c=1, d=1.2, growth is good, but not much different from the previous number.Ante level = 10, c=2, d = 1.4, growth is more pronounced, but may not have significantly exceeded the rounding threshold for the last calculation (A - A mod 10).With an ante level = 11, c=3, d=1.6, the growth is very significant, and you can see a significant leap in the graph with the blinds skyrocketing.

Note that the "difficulty" I want to express here is actually perceived, using modifiers such as "not bad", "obvious", "significant", etc. Essentially, after the ante reaches 9, the program already uses iterative power operations, but at 9 and 10 we "feel" that the performance is not as exaggerated.


Moreover

Theoretically, what is the highest level of blinds a player can reach? Considering that Lua's maximum positive floating-point number is about 1.8e308, at blind 38, the score is about 1e289. This indicates that at blind 39, this number will exceed the program's computing power. Videos online show that the target score is NAN and yours score NONEFF.

But at this point, the game is automatically over.

Conclusion

  • Game numerical design is also a science. The selection of parameters and functions tests the developer's interdisciplinary understanding of mathematics and game mechanics.
  • It's still interesting to see the analysis process of the game's underlying code! Although the question is not that complicated, finding the essence through the phenomenon can really make one feel intellectually happy.
  • In terms of code formatting, Balatro isn't really neatly written, which means you don't need a lot of programming skills to make a fairly fun game. Hopefully this will give confidence to the game creators haha.Welcome to communicate in the comment area!