📜 ⬆️ ⬇️

GameDev and candelabrum

A candelabrum is a candlestick, which is used to adjust the shape of a player's face playing unfairly.

Probably, many people remember the card game “Mariage”, which attracted players to CRT monitors more than a decade ago.


')
In this article we will talk about how they tried to give this game a second life and what came of it.



First call


For writing the game, one developer from Belarus was originally hired, who promised to release the application within two months, given that I provide him with a ready-made design. At the same time, as far as possible, a colleague should help him. The work was estimated at $ 2000 +% of sales. After receiving an advance of $ 1000, work began to boil. It was October 2011.

Reconnaissance


Initially there was no thought of porting anything. There was a desire to write a preference for the Android platform, which would become cooler than everyone else. We have not invented anything more original than the study of specialized literature, so we began to read everything that was available on the Internet. Among all the books stood out “Russian preference” Dmitry Lesnoy, with the head substantiating the mathematical base of the game, which was written by academician Leonid Mikhailovich Litvin. Unfortunately (although, rather, fortunately), it was impossible to buy a book, and in all online versions the necessary part of the book was simply missing. With courage, we wrote a letter to the author and, to our surprise, almost instantly received not only the missing part of the book, but also ... the source code for the Windows version of the game!



Combat reconnaissance and military tribunal


It would seem that there are sources, the work should move quickly. Already, but no, there was a deep lull. Only occasionally, like the rays of the sun through the clouds in winter, comets penetrated into the sun, which did not even allow to build the build. Closer to January and they stopped, the hand reached for the candelabra. After much controversy, the developer returned $ 500 and we broke up in peace. I note that in the same period the first version of the design was created, for which $ 275 was paid, the quality was appropriate.

Go to the contract army


January 2012. Spent 2.5 months and $ 775, nothing is done. By happy coincidence, a friend who decided to change the profile from the Delphi developer on Android, accepted my offer of cooperation and the work began to boil. In the future, all calculations with the developers passed only through Odesk.

Bridgehead grab


If you are not interested in technical problems that we experienced while porting the game, go straight to the “Offensive” section. Now we will brush away a tear of tenderness and tell you about what we had to face.

As already mentioned before, the availability of source codes did not mean a quick victory. The code was very confusing, the UI went along with logic. Many (including global) variables and fields of classes consisted of two or three letters, and the names of classes and methods contained unknown abbreviations. Suits and card ranks, betting levels were obtained as a result of magic bit operations. What prevented them from wrapping their function with a clear name is a mystery. It was necessary to comprehend much experimentally, trying to guess the purpose of this or that operation.


(Memorize this code snippet. Below we show its modern version.)

It took four months of hard work to create the first working prototype in Java. First, the structure of classes was created, which more accurately reflected the interrelations of various subsystems of the game. At each stage of development, we had a finished prototype, which was gradually enriched with functionality from the source code of Marijazh. They also had to be brought to mind in order to understand how everything in the code is organized, and also to create a generator of reference games for testing.

The first prototype had a significant drawback - it worked on the smartphone so slowly that it was simply impossible to play. Looking ahead, we say that the number of iterations in calculating the optimal course depending on the player’s level varies from 25,000 to several million, and many of the calls are recursive.
“Rewrite in C!” - Some acquaintances advised me, arguing that the java is retarding, but on C everything will fly. The hand again stretched to the candelabrum, but this time I wanted to embed myself, since in this case I would have had to throw out a few more months of paid work. This option was not pleased, but from the weapon we had only smooth-bore refactoring and small-caliber optimization. We applied it.

Fix at the turn


Obviously, the game with a slow-witted AI is not interesting to the user, so the first step was to speed up the algorithm to reduce delays to reasonable limits. We took HTC Desire as the minimum device, and Samsung Galaxy S2 as the average device. I also wanted to make sure that the port of the algorithm was made correctly and optimization would not break it. To achieve this goal, the original sources of Marijazh were “doped”. The program was taught to play the alignment by all levels of players at different conventions and write the result in an XML file. To do this, we had to spend a long and hard work to separate the interface from the logic in Delphi. We received similar XML from our Java code, then compared the result. Thus, we received about a million games, 70 thousand of which were selected as a reference. After each step of optimization, we drove them again.

What was done to optimize the speed of calculations?


As a result, we managed to achieve speed optimization tenfold (from the fact that one game was counted a few seconds on the Core i7 to the point that now an average of 5 games are calculated per second at the most difficult levels). And we did without rewriting even a part of the algorithms in C, which significantly simplified debugging and testing. Now our product works quite quickly even on HTC Desire, and if it does, it shows the progress of the calculations. There was no such thing in Mariage, although when the computers were still quite weak, the moves had to wait for several minutes.

Here is the result from the code that was given at the beginning of the article:



And this is how it looks live:



Go on the offensive


At the time of the release of the second prototype, there already existed preference versions on the market, so I wanted not to lose face and do something really good. To begin, we asked friends to play a couple of games and carefully watched the game. As a result, the interface has been significantly changed, and a new level of complexity has been added to the game - a schoolboy. Initially, a new level of complexity was not planned, but after my friend finished a bullet with more than 200 in grief and threw a phone at me, I realized that something very simple was needed. The current student does not just play poorly, he also helps the player! In order to keep the user in the game, we added the “Journey” mode, in which we offered to play in 20 cities with gradually increasing complexity of rivals from city to city. We believe that we succeeded. According to Google analysts, the average session length is about 10 minutes and more than 70% of players play in this mode. We didn’t promote as such, because Admob doesn’t advertise gambling, and it’s not worth doing downloads without receiving the same money in return. Tried to buy promo in LiveJournal, it did not give the result. Nevertheless, after the publication on Google Play and the announcement on a couple of forums, we hit the “Top 10” card games in Ukraine and the “Top 20” in Russia during the first month, thereby grabbing a solid piece of the market. For three months, our game has been downloaded by more than 50,000 users. I also note that the article on Preference on the wiki was written by the author of a competing product and we failed to add our link.



Guerrilla movement


Like any product, our game has a group of haters who periodically emit rays of hate in the forums and comments on Google Play. They are united by one and the same thought: “I have been playing pref for N years and have beaten everyone in my yard, and here I lose? Mukhlezh! ”It turns out that both our bots play together, they change cards, and indeed we give out bad cards in general ... Thanks to Google, which made it possible to respond to comments! Rating, of course, cannot be corrected by this, but at least morally it has become easier.

Help local people


I was pleasantly surprised by the help of players who were very pleased with our implementation of preference. During the first month we significantly improved the game, based on their feedback. Note that none of the development team is a professional player, so it was quite difficult to take into account all the game nuances.

The battles that we lost




Personnel


After the military tribunal, for the first six months a programmer worked on a full-time programmer, as well as night and weekend. He also hired a designer who left us, having done 50% of the work, motivating the refusal by deciding to quit freelancing and go to a permanent place. The next six months (and we were releasing on December 31, 2012 at 23-48), the same programmer worked in the evenings and weekends, after three months another young but very intelligent partner joined him, who initially took over the animation, and then performed all sorts of tasks.

One very talented girl also began to make the design. An experienced fighter came to the rescue in a difficult moment, who painted the avatars of all the characters. It is thanks to them that I learned that people sometimes happen to be in a raid or danje, and an order can be taken when the computer is not working.

The game plot was thought out by a kind uncle from Zamkadya, he also wrote a Russian version of poems.

I can not fail to note the help of many friends and people who are just not indifferent to the preference, who have done a lot to make the game really good.

Plans to seize the world


We are not going to stop at what we have achieved - work is already underway on the iOS version, as well as the Online version. I do not leave the links, the seeker will find it :)

Source: https://habr.com/ru/post/177467/


All Articles