fan or cool feature? Let's look at Foresight as an example

One day I came across an article about an employee who implemented a full-fledged game with an interface, opponents and other mechanics in an Excel book. As I continued to study this topic, I saw a whole world in which people, using products not intended for this purpose, implement various game mechanics. This idea popped into my head, and after that I always wanted to implement something similar myself.

Not long ago at work they came to me with an offer to prepare and take a developer certificate for the product “Foresight. Analytical platform”. Simply reading the documentation gave an initial understanding of the capabilities of the platform, and it was necessary to apply the acquired knowledge in practice. I was especially fascinated by the designer of my own forms in the Fore language, which reminded me of my student days and Visual C#.

I quickly got bored with creating simple forms, and I decided to close my gestalt with game development, since the platform was suitable for this on all counts. This is a product that is not entirely intended for game development, although the tools for this are present.

All that remains is to choose a game.

Game selection

About 20 years ago I sat down at a computer for the first time. There was Windows 98 there and I, like any child, immediately wanted to play on it. And there was one game that was not easy for me, literally – “Sapper”.

Later, when I understood the mechanics of the game, it no longer seemed so difficult, but then it was a challenge. And the memory of this was kept in my head for so long that there were simply no options for what kind of game to implement – I wanted to write my own “Mineweeper”. Moreover, now the standard versions of Windows don’t even have games anymore, and sometimes you want to relax a little nostalgically.

Project progress

At first there was Google Yandex. I didn’t want to reinvent the wheel, so the first thing I did was look for an implementation of the game in other languages ​​that were closest to me. A short search led me to a video course on creating Minesweeper in Python, so the reference was found and I could start adapting the logic to Fore.

Let me clarify right away that the game code is most likely far from optimal, and now many things could be done differently, perhaps even simpler. But the main goal of this project was to learn how to design forms, how to interact between different objects on a form, and to explore the boundaries of customization possibilities.

For example, now each cell in the game is a separate class, inherited from the base button class, in which I redefined and added my own methods (this, by the way, was also done for testing capabilities). Further, when I started testing the game, it turned out that if there are 100 buttons on one form, there is a slowdown when updating the field. This may be due to some of my non-optimal design decisions.

Below in the article there will be a link to my repository with the code – I will be waiting for your pull requests for optimization.

Description of logic

In this article I will not dwell in detail on the Minesweeper mechanics. All the code that will allow you to add a game to Foresight is available in the repository GitHub.

Some screenshots of the game itself - like the best publishers

Some screenshots of the game itself – like the best publishers

I did not complicate the example using Python or Java (although we can use modules in these languages ​​in calculations), everything is written entirely in the platform language – Fore.

The logic of the game is as follows:

  • There is a main form that the user sees on the screen. When the form is launched, mines are placed on the form and a field of tiles is created. Each tile is one button that the player can press.

  • Each tile knows whether it is a mine or not. Also knows which row and column it is in.

In my concept, only the main form knows the location of all the bombs, and only it can look at the adjacent cells to the one the user clicked.

Therefore, when you click on a tile, the following happens:

  1. The OnClick event fires on the selected tile.

  2. If the tile is a bomb, then a command is sent to the main game ending form.

  3. If the tile is not a bomb, then a command is sent to the main form to count the number of bombs on neighboring cells and show the user their number.

Why implement games in products that are not intended for this?

But why do this? There are software products that are designed for game development, and there are serious analytical platforms that are not. There are several answers here.

  1. Trying to solve a problem that is non-standard for the platform, we test it for flexibility to customer requirements and to the limits of our capabilities.
    How long will it take us to solve a non-standard problem? Will we be able to find answers to non-standard questions in the documentation, in help, on forums?
    As a result, we, as integrators and developers, can offer our clients optimal solutions to problems, and we understand how this or that client’s pain can be solved using the platform.

  2. Education. It is much easier to learn in a playful way, and games appeared for a reason.
    Using Windows as an example, all the standard games that came with the operating system taught users basic things – how to use a mouse, which was new at that time. Our “Mineweeper” was originally needed to train users to work with the right and left buttons on the mouse – Proof.

And now, in the process of creating the Minesweeper game, you can get acquainted with the basic syntax of the built-in Fore language, get your hands on writing code and learn how more complex concepts work – OOP, dynamic creation of elements, learn how to work with memory leaks.

results

Personally, this project allowed me to prepare for the developer certificate without boring reading of documentation, but with practical benefit. In addition, it became clear that many basic things in the language could be changed and configured as needed for a specific task.

One of the most key things to understand was the mechanism of interaction between two objects on the form, how to call this or that method, how data can be transferred between them.

And now we know that if our client needs to implement a special business process, then we will be able to correctly assess both the capabilities of the platform and the time that will be spent on implementation.

After finalizing this project, there were a lot of unrealized ideas left, both with additional mechanics for placing flags on “suspicious” tiles, and with a leaderboard with the best players or achievements.

After this project, I only had one question left in my head: If you can make a single-player game, can you make a multiplayer one?

Maxim Britvin

Senior consultant-developer of the EPM department at KORUS Consulting

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *