nedjelja, 24. rujna 2017.

Plan for 0.7 features

As promised, the feature list planned for next milestone, after two features are already done :). This milestone will more deliberately follow a way of working which emerged in the previous one: one under the hood change, one feature implementation and then preview release. On top of that I'll try to add more meat to the game and work toward establishing similar rhythm of implementing systems and adding game content.

Features planned for 0.7:
  • Save game preview, a small thumbnail image of a game state in a save game list. This one is already implemented and you can see it in action in previous release.
  • Organization traits. Previously a player could pick an organization he is going play as but it was not reflected in gameplay, every organization was virtually the same. With this feature each organization will have a preferred research field and it will advance faster within that field. It's not as groundbreaking as MoO II racial traits but I hope to design research in a such a way that each field would promote different play style. Also already implemented but will be included in next release.
  • Stareater brain is going to be a special star system, kind of like Orion system in MoO series but with more prominent importance. Controlling this system will grant owner an ability to control whole stareater and work toward victory condition: leaving stareater's pocket space.
  • Colony maintenance is a comeback for a feature before last rewrite but with more time in the oven. Each hostile planet trait will incure certain maintenance fee per population which is going to be payed by whole nation, not just that particular colony. It's similar how Sword of the Stars handled hostile planets and discouraged too fast expansion. Additionally global maintenance system is a groundwork for future mechanics (like espionage).
  • Population migration is another feature comeback but this one is as simple as it sounds. As colony gets more crowded people will try to migrate to more roomy places. I may complicate it with planet habitability being a factor in migration desirability but for now I'll limit migration range to planets in a star system. In some future version I might add interstellar migration.
  • Area of effect weapons are going to be weapons which damage all units in a tile. Top unit of a target stack will receive full damage while other units in the area are will get reduced "splash" damage. Another feature I'll try to push with this feature are torpedoes, missiles which travel on the map like ships do in order to reach target and can be shoot down.
Since I've already finished two the listed six features I may add more along the way but on the other hand there is plenty of non-feature improvements waiting to be done too. I seriously need to change GUI engine and that's a huge work. Fortunately it can be broken down to small manageable pieces but I still have to be careful with architecture. Then there are graphics. I'm working on procedural planet generator for minting high resolution cartoony planet images and it's progress is so-so. I have decent asteroid algorithm and rudimentary rock planet recipe which should work for Earth-like, Mars-like and Mercury-like planets. I'm still looking for good random stripe generator for gas giants and Venus-like could covered planets. For starships I've finally developed a tool which suites my style of drawing so there is an opportunity for updating existing ship graphics and include source code of images in version control instead of binary data. That's plenty of work to do, will see how much time and energy I'll have, my real life situation is about to get permanently changed.

subota, 16. rujna 2017.

Preview release v0.6.1

Features planed for 0.7 are... going to revealed later :). Actually I wanted to report on a new preview release packing new data engine and save game preview.

Download Stareater v0.6.1

Game preview is like a cherry on the top of data system rework. As the whole save format has been reworked, I've made save metadata more accessible. Previously the code had to read and parse whole save file to get save title and game turn number and when building list of saved games it had to do it for each file. Now it can read just first few lines from each file and read whole file only when actually loading a game. Preview data is also in those first few lines and it can contain whatever GUI needs to make preview image of the saved game. At the moment it contains turn number and star positions and colors but I can easily expand with occupied regions and power graphs or shrink it to just player colors for multiplayer games. That can wait because it requires more thinking what to show in preview since star dots on small map alone make too noisy image.


If you are really interested in feature list in upcoming milestone then you can take a peek at project's milestone task list. I promise to write more about it in next post :). Just one more thing about last post, I can't stress enough how important it was to change "state engine" to more native solution, I'll try a different angle at explaining it. Take a look at this image:


Previous solution contained a quite lot of "unclean" code meaning it was not fully supported by IDE (development environment) in some way or another. Engine for example was completely written in different programming language (T4) then the rest of the project (C#) and the nature of that language made it hard to write and debug. Instead of having IDE notifying me immediately when I wrote something wrong while writing the code I had to run the script in order to uncover simple type fellers and guess from cryptic error message where the problem is. Following script execution step by step was unsupported too and I had to resort to clumsy data dumping to find out where exactly the error is. At least that was the case in IDE I was using at the time, newer ones are a bit more helpful. Point of the engine was to generate C# code for data classes but it too had to happen through a bit more of T4 scripting in order to define which properties and behaviors particular class should have. Generated code should not be edited because T4 script would overwrite changes if retriggered so each kind of custom behavior has to supported by engine and used through class code generator script. In the end using all that generated code for big operations (copy, save, load) was relatively clean, there were some hoops to jump through in order to handle dependencies but nothing so dramatic.

New solution, as you can see from the picture is much much cleaner. Engine code is roughly equally in size as previous one but it's mostly nice and clean C#. There are few spots where a magic is used to generated code while application is running but it's kept to a minimum in both quantity and complexity. Even if something breaks there it's easy to debug. Data is now pure regular C#, no metaprogramming tricks. Well, class attributes have to have certain reflection attributes but let's pretend it's normal code, if nothing else it's very brief overhead. Now classes are free to have whatever constructor they need and set whatever property they want to default values and enjoy full IDE coding support in the mean time. This part was the biggest reason to change the engine and I'm happy with the result. Lastly, major operations are slightly simpler then before, there are still some hoops left but a little fewer this time. There, I'm done, hope this has convinced you :).

utorak, 22. kolovoza 2017.

New state engine progress

Last major release went well, all in all. The game attracted a few curious persons and one was very generous with feedback. Some of the easier suggestions (turn count in the corner, special equipment limit in ship designer) are already implemented and other are added on to do list.

What is going to be done for next major release? This will be reviled in next post, I'm still working on the feature list and I've already started working on something. I'm weighing how much refactoring should I do because I really want to clean up some things but the downside of refactoring is that features doesn't get made during that time. So I've started new milestone to by refactoring the biggest thorn in the side. Now is the best time while there is no psychological pressure to work on polish, feels like I have all the time in the world and it's better to do breaking changes early with plenty of time to test them thoroughly. In last version I've been working on removing text template code generators but I had to keep state handling ones due to complexity and their time has come to an end.

In Stareater code game data is split in following categories:
  • States - facts of the game world such as star positions, which planets are colonized and by whom, which technologies players have researched and so on.
  • Orders - how players want to change the state. This includes building queues, technology development order, audience request and so on.
  • Derivates - implications of states and orders. Population growth for example is calculated from colony's current population, population limit and "housing" building which converts industrial production to population.
  • Statics - assortment of stuff in the game. Which technologies there are, kinds of ship equipment, kinds of buildings and so on.
When it comes to juggling data statics are simple, they are loaded once and that's it, derivates are recalculated when needed so they don't require much management either but states and orders have to be copied, saved to a file and loaded back. Ordinary mortal programmer would simply write functions for each operation in each data type. Maybe I would too if it's was a smaller project but in this one there are currently 20 state and order data types with total of 82 attributes (members/properties/fields). That's a lot of stuff keep in mind and remember to update when adding new features. So like every engineer I've decided to let computer do the bookkeeping for me and that's where T4 text template came to play. I'd simply list which attributes a type has and for each attribute it would generate logic for initialization, copying, saving and loading. It sound awesome in theory but T4 is hard to debug (at least was at the time) and there were always some edge cases which were hard to solve with general approach.

Developing and updating T4 based solution took me at least two months, in total making it almost 10% of effort since v0.5 rewrite. New system already took a month to develop but I'm confident it won't take much time to maintain. Firstly, it already works, secondly it's easier to work with since it's pure C# code. I also simplified data a bit in order to make it work, some relations were really complicated and required a certain unintuitive order of operations to get stuff done.

How does this new "state engine" works and why didn't I implement it first time around? In C# there is something called reflection and I tend to call it "dark magic". It allows you to get information about data types while the program is running, information such as which attributes a type has, how they are called in source code, which types does the type inherit, reading and writing values where you normally can't and many more. All of this comes at the price of quite slow performance. Also there is another form of "magic", so called expressions trees which basically let's you  create more program logic while the program is running. At first I was concerned whether it's a good idea (how fast is compilation, would antivirus freak out) but I've found out that Microsoft's own database access functions use so it's not something foreign to the world. The price is only a slowdown on first use (compilation actually), further uses work almost as fast as native code. New state engine uses both schools of magic, reflection for gathering data and build up engine and compiled expression trees to do the actual operations but I tried to keep them to a minimum since they don't make very readable code. It's much more readable then T4 templates, true, but still not self-explanatory on a first glance as normal C# code.

This engine didn't come out of a blue either, I've been experimenting with technology a year ago and developed a small prototype project to test out those "magics". Now that a new engine is made, there is some minor code cleanup is left to do, full removal of remaining T4 templates and verification if all state and order data types save and load properly. God, I need to automate this somehow but only thing that comes to mind is to make a test suite which would take another month of making features. Back to compiling feature list for the milestone, one thing is certain, organizations are going to have a tangible effect.

utorak, 11. srpnja 2017.

Release v0.6

New major project milestone is done, Stareater has officially reached version 0.6. A few new features got implemented but there was many bug and stability fixes and code quality improvements.

Download Stareater v0.6f1

Major features of the milestone: 


Diplomacy - players can now call for an audience and negotiate treaties. Although bare bones, players can switch between peace and war, combat respects those treaties (you can't attack or be attacked if you are not explicitly at war) and code is ready for more nuanced diplomacy.


Refitting - a staple of  Master of Orion 2, built ships can be retrofitted with new equipment. Player can explicitly set which design is going to be retrofitted to which design. Also when a technology improvement gets developed, refit orders will be automatically issued to applicable designs. For instance when you get laser level 2, all designs with level 1 laser will be marked for upgrade.


Semi-exclusive research - another staple of Master of Orion 2 but in a less severe form. When a player makes a breakthrough in a research field he/she will get all technologies from that breakthrough but will have to choose priorities. Technologies with higher priority will be cheaper to develop to higher levels.


Space monsters - trope from basically all space games but especially important in this game. Unlike other 4X games your main goal is not to be dominant force in the universe (though you can do it as bonus objective) but to get back to "the real" universe. Stareater is a pocket universe which keeps you trapped and it's filled with space faring creatures which help it consume stars. Those creatures don't hold any special grudge against you but they are not concerned with your welfare either, they'd gladly make a star brighter and let it irradiate all planets in the system. Unlocking their secrets will be the key for leaving Stareater.
Minor features of the milestone:
  • Persistent ship damage - companion feature to refitting. Damage to ships in space combat persists after the combat and can be repaired at friendly star systems. Surplus repair points are used to retrofit ships.
  • Postcombat bombardment - similar to Master of Orion 1 and 2, after a space combat is resolved, winner can bombard (and in future invade) undefended colonies by just clicking on them. Previously attacker had to remain in space combat, move ships over a target and command each ship individually.
  • Weapon ammunition - some weapons like missiles and bombs now have limited ammunition in combat.
  • Hot seat multiplayer - multiple human players can play the game on the same computer. Technically this was possible prior v0.6 but now it's tested and some rough edges are dealt with.
  • Improved starlane generator - they now look more organic while ensuring whole map is connected and that each player has access to roughly similar part of the map.
  • Active planet and star traits - companion feature to space monsters. Celestial body traits now can have more complex behaviors then just being and not being. "Catalyzed" star trait can spawn "irradiated" trait on planets in system and expire after a few turns.
  • New rendering engine - not exactly a minor effort but from player's standpoint a less visible feature. Graphical objects are now handled in more organized manner, each scene simply lists where is what and underlying engine handles details like drawing order and draw state switching. Frame rate control has more options, from pushing GPU to work at max speed to battery conserving one. OpenGL version has been updated to 3.2 which allow easier use of shaders so there visual improvements too.
Under the hood changes:
  • Map settings from last game are remembered
  • Some of text templates are removed from code, replaced by different code structure
  • More ship images
  • More technologies which could end up in final game, not just for testing purpose
And more is to come. I'm tempted do to a lot more of under the hood changes, including better GUI library, restructured game data storage, add tests to prevent "f1" (hot fix 1) versions in future releases and so on. On the other hand I'd like to add more substance more quickly to finally get something really playable. I'll try my best to balance those too desires in next version.

subota, 24. lipnja 2017.

Bombardment Mk II

Real life got me busy again, it has been a while since last update but the last feature for v0.6 is done. Bombardment can be performed after victorious space battle.

New bombardment kicks in when attacker is at undefended colonies. Be it after defeating defender's fleet in space battle or by simply there being no space defenses at all. Rules for in battle and out of battle bombardment are virtually the same: damage calculation, ammunition limits and turn limit are the same. This also means that ammunition and turns spent in space combat are not available in bombardment phase. In essence bombardment acts like simplified space combat without unit movement, any colony can be bombarded instantly with all ordinance without spending turns on travel.


On top of this feature I've improved starlane generator so the map looks more organic and less like a crystal lattice. It was in rather a simple change, I've increased minimum angle between incident (coming out of a same star) lanes and decreased the number of extra lanes beyond the minimum required to connect all stars. It turned out that those extra lanes were major contributor for turning organic look to crystalline. Now, if 0% means minimum number of lanes to connect all stars and 100% means maximum lanes possible then new starlane density settings are as follows:

  • Few - 20% (was 33%)
  • Decent - 33% (was 50%)
  • Many - 65% (was 100%)
  • Maximal - 100%
Why stop on simple things when I can do complicated stuff too? Occasionally in maximum lanes setting there would be a few extra long lanes at the edge of the map, practically running along the whole edge. I've made an algorithm to remove them. It's something along the lines if a long lane was not there, find out if previously connected stars can still be reached via other lanes which are individually shorter and form a path which is not much longer then removed lane. Sounds simple but is a bit of a calculation intensive.

And now the plan is to fix a major bugs, polish a few things and finally release v0.6.

srijeda, 10. svibnja 2017.

Preview release v0.5.5

Another preview build is ready. Took some time, again, but a lot of new goodies got included.

Download Stareater v0.5.5

The biggest addition is diplomacy mechanic. It was described in greater detail in previous blog post so I won't repeat myself. That leaves us with a number of under the hood improvements and new technologies. My "tech tree" draft is shaping up and I'd say it's developed enough to start adding it to the game. So far I've added two out of eight technology tiers and I plan to add third by the end of v0.6. It amounted to whooping 46 entries which naturally exposed an UI issue in library :).

Which brings us to under the hood changes. Aside from fixing panel scrollbar to show more then one screen of technologies, I got around unifying "name" and "description" localization tags into one generic "lang code". Now items (technologies, ship equipment, ...) have only one localization entry and name, description and future library entry are automatically obtained by applying appropriate prefix. Debugging has also been improved by passing around a file name of the file being loaded which made it possible to print which file has incorrect format. It sounds a bit strange to not have that already but the thing with Stareater is that the code is split in two parts: game rules (core) and user interface (UI). Core should know as little as possible about the world outside of game rules and that includes file management. Ideally UI part should provide all data sources (which don't have to be files) to the core. Now the problem is that core knows when the data is wrong but UI doesn't know when core is analyzing data and which file is being read at the moment. So I made that along with data stream there is a little tag with "source info" which for now contains the file name.

Another quality of life improvement for development is inclusion of texture atlas generator to UI code. Atlas is collection of smaller images (planets, ships, stars, ...) into a single image and up until now it was generated with external tool which had to be run manually every time there was a new image for a game. Now the game can automatically add the image and let me know which ones were not prepackaged so I can run the tool before publishing a release.

Then there were bug fixes, a concurrency issue between turn processing and read only view (UI when next turn is being calculated but player can still look around the map from previous turn) was fixed. NVidia bug is hopefully fixed, I'd need somebody to confirm that. For the moment I'm using unofficial homemade OpenTK build while OpenTK maintainers are preparing the official one which should be published this weekend.

utorak, 18. travnja 2017.

Peace by deafult

Peace is now a default state, meaning diplomacy has been implemented. In other games in the genre, even if it is called peace, by default you are neither at peace nor at war with your neighbors. In Master of Orion for instance parties have to form a non-aggression pact in order to stop each other from engaging in combat. Without it you are free too attack each other and still enjoy trade treaties if neither side explicitly declares a war. Sure, an AI will automatically declare war every single time you attack it's ships (even if you let them retreat without casualties) but when AI attacks you it's "only" a friendly rub and you end up being rude for feeling offended.

Peace in the Stareater on the other hand assumes non-aggression pact. Picking on targets of opportunity (weak fleets, unprotected colonies) is strictly forbidden before formally declaring a war. Natives on the other hand don't respect human customs so they are always treated as enemies.


What is implemented at the moment is public relations screen where you can see your contacts with other players and see which treaties you have with them. From there you can call for an audience which will be held after hitting next turn. During the audience you can declare war or offer peace. For now this is it and AI will go along with whatever you ask of it. It will take some fleshing out but the idea for the future is to have "public opinion" feature where each civilization population holds an opinion about other civilizations. If opinion is too low then war can be declared and trade treaties will be harder to form. If opinion is very high then cease fire must be declared and war between those civilizations can't be declared again.


It was a bit boring to implement this feature, mostly due to sizable amount of GUI involved. It doesn't look much but there is quite a number of things inside the things. At the end it became interesting and I even did an extra mile to finish an old task of including undefended colonies to space combat check. There are not many tasks left in the backlog for v0.6, this milestone is going to conclude faster then I've anticipated.