Updated: I know Crypto

I’ve been hard at work on:

So today’s update is short, and full of teasers.

Edit: I was in such a hurry, I forgot the post metadata (categories and tags).
Did you know that the NSA kills people based on metadata?



Yes, that’s really it. More to come in future posts.

Advertisements

My First Starcraft 2 Mod: Resource Rewards

Instead of writing a blog post over the last two days, I ended up publishing a Starcraft 2 Mod: Resource Rewards. Starcraft 2 is a real-time strategy / building game, and the mod rewards players resources for killing units and other players. (Normally, players must harvest resources from mineral and vespene patches.) The mod also recycles resources into patches, just to keep the game going longer.~

The programming possibilities of the Starcraft / Warcraft 3 / Starcraft 2 engines have always intrigued me, and I’ve worked on a few versions of this mod over the years. I can’t remember if I ever tried the mod on Starcraft. I’m pretty sure I started on the Warcraft 3 Mod/Map Engine, which was very limited. I had to enter all the unit resource values manually, in a huge lookup table. I didn’t like the quality, and I don’t ever think I published the mod online.

I re-did the mod for Starcraft 2, twice. The engine has a unit resource value lookup function, so that makes the basic implementation easy. I added the recycling feature, which is surprisingly complicated, and filled with nasty edge cases.+ I also included a feature which would spawn extra mineral patches while recycling, but it got cut from the final version, because adding new (stationary) units to a map is incredibly hard to do well.#

Despite all this programming (or, perhaps, because of it), I’m not a very good Starcraft 2 player. I just can’t click fast enough, and I haven’t invested the time to learn strategies by instinct. And it seems that it’s easy (for me) to lose online, and lose badly.* It makes it hard to start learning. And maybe I’ve learnt some really bad habits along the way. I used to play World of Warcraft with an external, 5-button mouse, linked to various shortcuts. Perhaps that would be the way to go, if I ever wanted to get better.

I had a moment of indecision when I deployed the mod publicly for the first time. Out of an over-abundance of caution, I uploaded a “Locked” version, which means that no-one could see how the mod works, or use the same logic in their own mods. But I’m generally against copyright, and there’s no value gained in keeping the source closed here. I didn’t really mind people re-using my code. So I made it Free Software (Open Source) ~~, under the GNU GPL Version 3, or any later version. This ensures that any mods based on my mod remain Unlocked, and licensed under the GNU GPL, or compatible licenses. The risk is, of course, that someone copies the code, Locks their mod, and redistributes it. It would be hard to tell if that happened.


Edit: I was in a hurry, and I forgot the post summary.



~The fact that the game ends soon after you get to play with all the fun units has always annoyed me about Starcraft.
+ How do you divide an arbitrary amount of minerals between several sites? What if it doesn’t divide evenly? What if the dead unit is worth 30, and there are 300 sites? I could have used the floating point resource amounts, but they’re displayed as integers in-game. (And I have no idea whether they are rounded internally or not). So I used integer amounts, and implemented an “unprocessed” accumulator with a minimum accumulation before recycling. It seems to work well.
# Do you put them randomly, near the existing patches, or away from everything else? There aren’t good enough distance, grouping, unit placement, and error handling functions, even in Starcraft 2.
* I don’t like losing. It feels too much like failure!
~~ There is a difference between Free Software and Open Source: in short, one is focused on ethics – the continuing freedom to use, modify, and redistribute software. The other is focused on development – getting the source code out there, even if there are restrictions. I recognise the difference, but I’m often pragmatic about choosing the software I use (I use closed-source OS X, after all…)