ponedjeljak, 25. ožujka 2013.

New game finished

"New game" GUI is almost finished, actually it's in that state for few weeks. Part that currently stands between almost finished and finished is map preview. There are few things under the hood that have to be implemented beforehand so by the time the "New game" GUI is finished, the main game GUI will already be in the development. So I'll take this opportunity to write about new stuff in new "New game" GUI.

Obviously the current design differs from original concept (compare the image above with the image in the post from November). First of all the "New game" is not a single window in the process. Main window provides overview of selected settings and opens other windows for specific settings. I figured it would be cleaner to separate and have larger GUI form each group of settings than cram everything on a one big window.

Quantity and quality (color, organization, human or AI) of players is defined in "Player setup window". Once I get some spare time I'll add default "confirm" button to make it consistent with other windows and when I get sensible drawing tool (or skills) I'll add visual description for a player type in the list of players. Imagine it as human or computer icon inside color rectangle. What is not seen on the image above is support for multiple AI implementations. AI logic is contained in plug-ins, in DLL files that have one or more classes with certain interface. That way it's easy to add and change AI implementations and no implementation receives special treatment including my own.

Starting conditions setup window is for setting up initial population, infrastructure and number of colonies. I was thinking about having options for adding starting fleet and technologies but that is for future work when I'll have too much spare time :) (and when technologies and ship designs are reimplemented). Oh and one sexy thing that is already implemented are magnitude prefixes. Instead of writing 1500000000 simply write 1.5 G. Valid prefixes are k, M, G, T, P, E, Z, Y (as in kilo, mega, giga, tera, peta, exa, zetta, yota).

And finally the map setup window. Parameter assortment depends on map generators which are, like AI implementation, defined in plug-ins. Map are generated in three steps: positioning, connecting and populating stars. Positioning step determines number and positions of the stars. Second step connects stars with wormholes. In the final step star types are decided and populated with planets. Each of these steps is implemented in separate plug-in so it's possible to mod only part of map generation process while reusing other parts. In case there are more then one implementation for a certain step, GUI will show a dropdown menu for choosing one. Big black area is currently a place holder and will be used as map preview once I implement map generation steps (for now there are only interfaces and empty implementations) and draw new images for stars and wormholes.

As you can see there is a good deal of moddable parts. And there is more. As you may have seen on my main blog I've been trying out parser generators. One of result of such work is a parser that could crunch normal infix expressions. In previous versions of Stareater numbers in data files (such as food per farmer) were either constants or expressions in prefix or postfix notation (Polish or reverse Polish notation). Why were they in a text file instead in code in the first place? To make balancing easier (modding support is just a bonus). It's easier to tell a friend which number to change in text file than how to navigate and recompile the source code. And because I felt they are kind of configuration data and should be outside the source code. Now it's even simpler, with infix notation. I admit I overdid some things but I believe it will pay out. Just for the record writing a syntax for infix parser with proper operator precedence and associativity is less than 2 hour job but attributing that grammar (writing C# code for actions when certain terminals or non-terminals are matched) took me almost 20 hours.

Next thing on the list is to complete the map generator and have galaxy map rendered as soon as possible. I'll probably make simple map generator without resource balancing and making sure home systems are "fair" than implement map rendering and do the rest of the map generator afterward.