Breaking news
Match Preview & Column #12 -

The code for the blockbuster game “Balatro” resonates with people as it is described as “a feat of brute force.” Even if the code is dirty, it’s okay as long as the game is completed and works properly – -

--

A program required when creating a game. When writing that code, it may be necessary to have an easy-to-understand structure, such as “coding rules.” Meanwhile, a user has released part of the code for Balatro. Although it has attracted attention due to the heavy use of if statements in the code, it also seems to be gaining sympathy as an example of how “you can complete a game with almost no problems even with difficult-to-read or complex code.”

Easy to understand code

Creating a game basically requires writing a program, such as writing source code using a programming language. There are a variety of programming languages, including “C++” and “C#” as well as “Java” and “Ruby.”

Furthermore, not only in game development, but when creating complex programs, there is a tendency for efficiency and readability to be emphasized. In other words, they try to conserve hardware resources such as memory and CPU on game consoles and PCs, and to make it easier to share work among developers. In the latter case, for example, it may be necessary to rewrite or add some code to correct a bug or add content. In this case, especially when multiple people are involved in development, the person who originally wrote the code may not always be responsible for the work. Therefore, it may be necessary to make the code easier to understand by using techniques such as naming conventions for variables, annotating comments, and adjusting indentation.

This time, a user posted an image that is part of the code for the roguelike poker game Balatro. This work was released in February of this year, and is a popular work that has received high praise and sold over 1 million copies in about a month.

The post that appears to have published the code for Balatro without permission has already been deleted at the time of writing. However, LocalThunk, the game’s developer, responded to the post, and in response, he also posted an image that appears to be part of the game’s code.

Code with a lot of if statements

It seems that the original post, including the reply post, contained part of the code that made extensive use of if, else-if, etc. From this point of view, some users who have witnessed a series of codes have commented that they have poor readability, such as being difficult to read or insufficiently optimized. If statements are commonly used to implement conditional branching in programs.

However, depending on the program, the conditions may be complex or the number of branches may be large. In this case, problems may arise such as multiple nesting (nested structure) or the large number of branches making it difficult to understand the structure of the program. For this reason, programmers tend to avoid long if statements as well as switch statements.

But it’s fine as long as it moves

On the other hand, surprisingly, when it comes to the code of Balatro, more people say “this is fine” or “the code is complicated but it’s okay” than “it’s hard to read.”https://twitter.com/maxbittker/status/1782645521888247956/quotes. In particular, “Balatro” is a personal development by Mr. LocalThunk, so even if it is difficult to read, it is fine as long as the person in question can read it. In addition, the game does not implement any complicated logic, and no fatal bugs have been reported. Users generally only see the completed game, so even if the code is hard to read, it can be considered a success as long as it doesn’t cause any visible problems.

In addition, user reactions have resonated with a number of points such as “I end up lining up if statements.” Some creators have even posted part of the code for the games they are developing, saying, “I am using a similar method.”

By the way, not only Mr. LocalThunk, but code that ignored readability and efficiency has attracted attention in the past.For example, hinyari9, the developer of “Molten Marfusha”, shared part of the code for the same work.https://twitter.com/hinyari9/status/1777577954358493410. The corresponding code related to high score text, etc. is written using if statements, and it can be seen that it has a multi-layered nested structure. Regarding this post, Mr. Naru of Ederuwaisu, who worked on the development of “Tenho no Sakunahime”, also commented, quoting, “In the end, this is the code that will allow us to complete the game.” Particularly among individual developers, there may be a tendency to prioritize completing a game in a way that is easy for them to create, rather than ease of viewing or maintainability for other programmers.

In addition, there are cases where “methods that are easy for programmers” are emphasized in team production sites.For example, in January of this year, Yutaka Ito, the technical director of Ryu ga Gotoku Studio, announced that part of the code for “Ryu ga Gotoku 8” was released.https://twitter.com/YutakaIto_RGG/status/1745050214476677561It became a hot topic. In the series of posts, he said:https://twitter.com/YutakaIto_RGG/status/1745407497480147438”, revealing that there are no detailed rules for writing. According to Ito, after 20 years of experience, he has come to the conclusion that it is best for programmers to be able to work efficiently and without stress, rather than worrying about the details.

When it comes to programming, it is best to ensure that the code is easy to read and maintain. However, if forcing the team to follow the rules and customs of the team causes delays in production or causes stress, it could be putting the cart before the horse. “Balatro”, which attracted attention this time, can be said to be an example of how game development does not necessarily require “clean” coding.


The article is in Japanese

Tags: code blockbuster game Balatro resonates people feat brute force code dirty long game completed works properly -

-

NEXT “Git for Windows 2.45.0” released – Preliminary support for reftable and SHA-1/SHA-256 interoperability functions