
There have always been some closed societies in the world that are accessible only to a limited circle of people. In order to get there it was necessary to have something unusual. For example, ride a
Bentley or smoke a
Behike .
But I am now talking about a society where not money, but knowledge serves as an entrance ticket. Yes, yes, you will not believe, but I'm talking about programmers.
After all, only we are able for days to perfect the algorithm, only we can indefinitely be engaged in designing and improving the architecture of the project, drawing to no one understandable UML-diagrams and strange patterns. But there is one more type of occupation, a certain closed club for initiates, which killed more than one thousand hours, raising the professionalism of its members to the skies. I'm talking about Games for programmers.
')
There are a huge number of them, each game is interesting in its own way, each has its own architecture, its own
API-interface . Since it is impossible to cover all of them in a separate note - I decided to start a series of notes about various games.
PS Created an open blog
Games for programmers .
Colobot
The game was released on August 20, 2001, and it implemented a fairly high-quality 3D graphics for those times. First of all, the game was created for children. But as in the case of the children's railway, adults play the most part, of course.
Game developers provide us with a whole world, with all its enemies, limited resources and, of course, opportunities. As a basis, the already proven mechanism in the game-strategy was the resource mechanism that is needed for the construction of buildings, robots and the realization of your sinister plans. But resources, of course, are running out quickly and need to be constantly mined.
Programming language CBOT
All the programming in the game takes place in a certain CBOT language, much like the syntax of either C ++ or Java. The language itself is powerful enough, and allows you to realize almost any of your fantasies.
You can declare variables (using built-in types), use for, while and do loops, create not only functions, but also classes and objects.
All communication of your robot with the outside world is based on interaction with other objects, which are a huge amount in the game. Also provided are ready-made functions for calculating distances, nearby objects, engine management and other trifles, which allows you to concentrate on the main idea.
The code is written directly for each bot. You can even write several different programs for the same bot, and run the code you need at the right time.
The game contains a fairly simple debugger (
debugger ) that allows you to step through your code step by step, and immediately observe the result.
It should be noted that for me the code editor was not the most convenient. And the documentation, all the time dumped at the beginning, periodically took me out of a state of calm.
Before moving on to a serious game, you will be asked to complete a course of a young fighter, where they offer to solve simple puzzles. Let's look at a similar problem:
You need to write a program for the robot so that it goes through all the blue pluses. The distance between each turn is 20 meters.
For example, the move function (12) politely asks the robot to drive 12 meters. And the turn (90) function will rotate it 90 degrees.
Our program for the robot will look like this:
// , // . extern void object ::Solution( ) { move( 20 ); // 1 turn( 90 ); move( 20 ); // 2 turn(- 90 ); move( 20 ); // 3 turn(- 90 ); move( 20 ); // ! }
// , // . extern void object ::Solution( ) { move( 20 ); // 1 turn( 90 ); move( 20 ); // 2 turn(- 90 ); move( 20 ); // 3 turn(- 90 ); move( 20 ); // ! }
// , // . extern void object ::Solution( ) { move( 20 ); // 1 turn( 90 ); move( 20 ); // 2 turn(- 90 ); move( 20 ); // 3 turn(- 90 ); move( 20 ); // ! }
// , // . extern void object ::Solution( ) { move( 20 ); // 1 turn( 90 ); move( 20 ); // 2 turn(- 90 ); move( 20 ); // 3 turn(- 90 ); move( 20 ); // ! }
// , // . extern void object ::Solution( ) { move( 20 ); // 1 turn( 90 ); move( 20 ); // 2 turn(- 90 ); move( 20 ); // 3 turn(- 90 ); move( 20 ); // ! }
// , // . extern void object ::Solution( ) { move( 20 ); // 1 turn( 90 ); move( 20 ); // 2 turn(- 90 ); move( 20 ); // 3 turn(- 90 ); move( 20 ); // ! }
// , // . extern void object ::Solution( ) { move( 20 ); // 1 turn( 90 ); move( 20 ); // 2 turn(- 90 ); move( 20 ); // 3 turn(- 90 ); move( 20 ); // ! }
// , // . extern void object ::Solution( ) { move( 20 ); // 1 turn( 90 ); move( 20 ); // 2 turn(- 90 ); move( 20 ); // 3 turn(- 90 ); move( 20 ); // ! }
// , // . extern void object ::Solution( ) { move( 20 ); // 1 turn( 90 ); move( 20 ); // 2 turn(- 90 ); move( 20 ); // 3 turn(- 90 ); move( 20 ); // ! }
// , // . extern void object ::Solution( ) { move( 20 ); // 1 turn( 90 ); move( 20 ); // 2 turn(- 90 ); move( 20 ); // 3 turn(- 90 ); move( 20 ); // ! }
// , // . extern void object ::Solution( ) { move( 20 ); // 1 turn( 90 ); move( 20 ); // 2 turn(- 90 ); move( 20 ); // 3 turn(- 90 ); move( 20 ); // ! }
// , // . extern void object ::Solution( ) { move( 20 ); // 1 turn( 90 ); move( 20 ); // 2 turn(- 90 ); move( 20 ); // 3 turn(- 90 ); move( 20 ); // ! }
As you can see, behind the robot machine there is a green cylinder. This is one of our resources. While the robot is moving, the energy gradually decreases and as a result our robot may stall. After that, the only way to revive it is to replace the battery.
Localization
For children who want to learn programming, English could be a significant barrier.
Thanks to the already non-existent company Fargus, there is an excellent Russian translation. The translation with which I was familiarized was done perfectly.
All documentation is fully translated, I have no comments.
Usability
Usability in the game is lame in both legs. I spent about 40 minutes to understand what was happening. What resources are, how to get them, and how to get ready-made robots from them, I learned by pure chance.
For a beginner, most of the moments seem incomprehensible, worse than that, they can make him quit the game forever. I did it at the beginning, but then I came back and tried again.
General impressions
Moving from simple missions to more complex ones, constantly learning different aspects of the language, the player not only learns programming, but also learns the basics of algorithms.
When simple missions you already become boring - it's time to go to the main part of the game. For example, you will need to move out on an unknown planet, build up there (either with the help of robots, or manually controlling the astronaut) and perform some task. For example, kill all the ants.
It should be noted that the possibility of automation is truly limitless. You can automate the construction of new buildings, new robots (for example, flying or tracked), the search for minerals, the extraction of energy, recharging, the protection of your territory and other small details. The developers have provided us with a very convenient abstraction from unnecessary details, allowing us to focus on achieving a specific goal.
It is impossible not to notice that Colobot has excellent documentation built in which many OpenSource projects will envy. Everything is painted simply and without unnecessary details, examples of use are given. All documentation is relinked, so it's very convenient to navigate through it.
But in the game there is an annoying restriction on the length of the code - no more than 20,000 characters for one program. What the developers did for this is not clear.
On the
official website you can also find a fairly large archive of ready-made programs. Use the already written programs, improve them and send them back to the site. Begin to finally finally contribute to the great cause of OpenSource!
Ceebot
Not to mention that there is a version of Colobot for educational institutions. Ceebot is developing quite confidently, and even got its own website
http://ceebot.org , where various training material is published.
The version for educational institutions contains much more functionality, a large number of different tasks and missions. There are even
special notebooks for schoolchildren.
What is it worth programming a
football game and a
race of robots !
Want to participate in a fight with a familiar programmer? No problem,
Arena mode is available for you! Prove that you can do better programming in practice!
You can also check out a small
video that I found on
youtube.com that illustrates the programming process in Colobot:
youtube.com/watch?v=RlyKxjKXQcYThe official site is available demo version of the game for
download and review.
And do not forget to advise this game to familiar boys (girls?) - suddenly this is the future genius of programming!
If you are interested in my articles, then there is a hack that allows you to read them before the release on habrahabr: subscribe to
my blog , well, or
twitter .
Good luck!