CodeCraft belongs to the genre Programming game . Many of you probably know about the HabraWars project or about other Programming games. That is, the desire to write an environment for programmer battles arose among many. Here I, for example, had this idea. Its distinguishing features are:
The game world is a battle of two fleets of space ships.
The need for strategic superiority over the opponent
Management is possible both by individual units and by groups.
3 types of units
Tactical and strategic view
2D
Players - Library Plugins
2 levels of abstraction for interacting with the game. About them later
Easy debugging
Maximally simplified player writing process
There are documentation, manuals, examples
Why did I decide that the environment for programmer battles should be just that? Yes, I just always imagined mental combat as a competition of strategies, rather than single units. Otherwise, it’s not the strategy that is programmed, but the behavior, it turns out more like a shooter. It is much more colorful to look at the algorithm of the armies behavior: even rows of phalanxes, which methodically crowd out the enemy, packs of units that rush through, cunning maneuvers with fast units, unexpected strikes from the rear, a classic victory over a stronger rival thanks to the environment, etc. In many ways, the game is inspired by drawings from history textbooks, where conventional graphic images of different types of troops and their movements are noted. On the most boring pairs, imagination set them in motion, creating the concept of CodeCraft. ')
Story
The idea of ​​creating the game came to me like this: it was necessary to diversify my birthday, where only programmers were collecting then. So began the creation of the project. The idea was supported and soon joined the development of Mad_Fish . In the beginning, unit management was something like control in HabraWars. A player could turn a unit, fly forward and shoot if charged. The difference was in the possibility of a ram, which is almost meaningless for single battles, and in managing accelerations, not speed. Everyone invited to the DR was given the task: to come with his player. That is, bring it on a flash drive. It turned out that the created players were terribly stupid - the one who at least did not fire on his own and did not ram them won. Therefore, the non-shooting and non-moving player sometimes quite confidently won. After the holiday, I realized that avoiding rams, friendly fire and such things are routine things that are not interesting to play.
Simplicity
In practice, it became clear the need for extreme simplification of the management of units. Therefore, now there is an opportunity to write only what is interesting. I created standard implementations for the behavior of units and groups of units - the EtalonAI library. For example, the code
foreach (UnitPilot pilot in friends) <br> pilot.AttackClosest(); <br><br> * This source code was highlighted with Source Code Highlighter .
is already an adequate algorithm for combat. A unit can also be ordered to hold a position, attack a specific enemy, fly to the indicated coordinates, or wait for orders. A unit has a list of units close to it, units, enemies that aim at it. As well as all units are available in the lists of friends and enemies. To control a group of units, you can create a squad. The example creates a detachment of ten fighters.
DestroyersSquad1 = new SquadronColonel(friends[0], game);<br> for ( int i=0;i<10;i++)<br> DestroyersSquad1.AddUnit(friends[i]); <br>
Further, the whole squad can be sent to a given point.
DestroyersSquad1.GoToOrder( new GameVector(-3000, -2000)); <br>
You can order to move "through the attack"
DestroyersSquad1.AttackOrder( new GameVector(-3000, -2000)); <br><br>
You can set the type of building - line, rectangle, wedge or pack (without building).
Creating your own geometry is also possible. There are also orders to attack the nearest enemy, ramming the enemies (by the way, a useful thing is to destroy the enemy cruiser with fighters)
It is just as easy to investigate the enemy - the class EnemyAnalyzing periodically conducts the clustering of enemies - that is, you can easily find out which teams your opponent has divided the fleet
Working with geometry is also taken into account - the GameVector vector class contains methods for rotation, vector math operators are overloaded. There is a class Angle, which allows you to fold the corners, without fear of getting a thousand degrees, to find the difference, the distance between the corners, etc. for more details see documentation.
Of course, standardization to such an extent excludes the possibility of creating a unique behavior of a unit, a particularly cool Jedi-Chacnor fighter, but the game is strategic in ideology. In addition, as mentioned above, there are two levels of abstraction of interaction with the game: the first is a high-level one, where the player indicates who to attack or where to fly the squad and what order; at the second level, the player indicates directly the linear acceleration, the acceleration of the rotation of the unit and the moment of the shot. So the units were controlled until the birthday. It turns out that the opportunity to get confused and make Chuck Norris remains.
Debugging
There are several ways to debug
Display text on behalf of the player. The game class has a method SetText (string text). You can use line break \ n
The output of the text on behalf of the unit. The unit has a Text field, the contents of which will be displayed on the screen. You can also use line breaks.
Geometry output. The game class has a GeometryViewer field, whose class has methods for drawing a rectangle, a circle, a line and a point. The color is set (transparency is allowed) and the figure itself. By the way, the structure of the figures is also its own, have methods for calculating intersections.
The settings file allows
Enable or disable debug output
Run the program in full screen or window mode
Change the number of units of each type for each side separately (for example, as I learned that 100 fighters are “standing” 13-15 corvettes)
How to write a player
Writing "Hello world" and an adequate algorithm takes only a couple of minutes. The player can be written in any .NET language. For this you need:
Connect the MiniGameInterfaces.dll library and, optionally, EtalonAI.dll for a pleasant writing.
Inherit the AI ​​class, overload the Init and Update methods in it.
That's it. It's almost a complete guide.
Details
The game was written in C # using XNA, so pardon, Windows-only. After all, I did not expect to show anyone other than friends, but all the same, C # is a complete convenience. Mad Fish is now porting a game for Linux. Control keys
Page up and page down - increase, decrease simulation speed
Home and end - the distance and approach of the camera.
Arrows - moving camera
Pause - pause
Esc - exit
Conclusion
I hope to develop the project further. For example, graphics are humanly done and all that. Mad_Fish is currently porting CodeCraft to OpenGL, and says that Microsoft shouldn’t depend on) But the most interesting thing is of course to download a player written by one of you; look at his tactics; figure out how to beat it; load your player winning it and wait for the opponent's response. Download strangers and add your players here.