C2DM is dead, long live GCM!

Posted by

It’s been over a month since my last update, and for that I apologize. I’ve been working hard getting the combat system stable and robust and I’ve made great progress in that area. There’s not much to show at this stage, but stay tuned for a walk-through of combat in the next week or two.

Anyway, I wanted to post an update just so it’s clear I’m still area and also to point out something interesting I discovered: C2DM (aka the Android Cloud to Device Messaging Framework) has been deprecated, in favour of GCM (aka Google Cloud Messaging for Android).

Now this news is pretty meaningless for most users, but for developers it’s great! C2DM was a bit of a hassle and it had a number of limitations that made it difficult to use. But the benefits of GCM are clear:

  • No quotas (C2DM had a per-day quota and requesting more was a pain). When you think about it, a quota is kind of pointless anyway because spamming users is not very useful since they’ll just uninstall your app anyway.
  • Larger payloads – up to 4KB, which lets us put more context into the notification
  • Structured requests (instead of just plain text). This isn’t that big of a deal, since we used to format data as JSON and the “structured” format of GCM is also JSON, but it’s nice that it’s now natively supported

Unfortunately, it means another day or so lost as I migrate all of my code from C2DM to GCM. But it’ll be worth it!

Progress Report, October 2012

Posted by

In our last post, we left off with my thoughts on a new kind of resource for the game: cash. I wanted something that could be used to trade between empires and also something that helped to give a slight advantage to defenders over attackers (i.e. by requiring you pay for fuel, it's easier to defend than it is to attack). I haven't posted for a few weeks since then, but not because I had nothing to say: au contraire, I've been really busy implementing a bunch features that I'd like to go through now.

Changed to existing UI

First off, I've changed the layout of the starfield page a little, to allow for a higher information density.

Starfield view, new layout

As you can see, the list of planets/colonies and fleets are now side-by-side. There's a new button, "Intel", which I'll get to in a minute. "View" will bring up the solar system view (as will tapping on a planet). Tapping on a fleet will bring up the empire overview activity, with that fleet already selected.

Also, a minor – but important – change in the solar system view page:

Solar system view, minor changes

I'll probably be changing the layout of the lower section to be similar to what you see on the starfield view, but I just want to draw your attention to the top-right. I've added a limit on the maximum amount of food and minerals you can store (500 is the default). You can build Silos to increase the amount of storage (each silo adds 100 to the limit). Also in the top right, you can see the rate-of-production for all colonies combined for each of food and minerals.

If you're wondering why the selected colony has +91/hr for food but the overall rate is only +75/hr, that's because the indicator on the bottom-left doesn't take into account what's being used, only what that colony is outputting.

So what happens if we start building stuff?

Building a fighter

The fighter is a new kind of ship I've added. It's really just a place-holder for now, since we'll have lots of different kinds of fighters in the final game. You'll also notice I've added the slider down the bottom there that lets you build a bunch of ships all in one go. I figure you'll want to have lots of ships building, so this is much easier than building them one-by-one!

Building fighters

The fighters will take 3 hours, 44 minutes to build. Building 50 fighters obviously takes 50 times as long as a single fighter. Also, now if we go back to the solar system view, we can see the minerals that are being used to build these guys:

Building, using up minerals

Now you can see that it's using up 172 minerals per hour, and in fact we're already down by 49. The fighters are scheduled to finish in 3 hours, 44 minutes so if you do the math, you can see that we'll actually run out of minerals before then. But that's OK, the estimated completion time actually takes that into account and is the time the fighters will finish even though we'll need to wait for minerals by the end.

Scouting and NPCs

One big thing I've added to the game is NPCs. It's a little boring when you're just starting out because there's no other human players around (that's because we don't want to start you right next to a powerful player who'll just wipe you out in the first go – by starting you away a little bit, you have a fighting chance to establish yourself before you meet anybody else). NPCs are shown in the game as being "native" – kind of like civilisations that have not yet discovered interstellar travel. So you can attack them, but they won't attack you.

So lets check one of them out. First, we'll sent a scout over to a close-by star:

Sending a scout to a nearby star

You can see that we indicate the distance and estimated time of arrival of the movement and also – importantly – the cost. The cost to move a fleet is different for the different types of units (for example, a colony ship is very expensive, fighters are quite cheap) and the number of ships in the fleet. Scouts are fairly expensive to move, but typically you'll only send one at time.

Scout movement in progress

Here we can see the scout is making progress. The estimated time remaining is 21 minutes. If we click on "Empire" and go to the "Fleets" tab, I've also added an indicator showing the fleet is moving:

Fleet list, with moving scout

With play-testing, I'll be adding more details to these screens as they become necessary, but already I think this is a good start. When the fleet arrives, you get a notification, and when you go back to the game, you can select the star (Meg) in our case, and click the "Intel" button to bring out a report that the scout generated:

Intel Report

You can see from the report that the native NPC has a bunch of fighters on the star, and they all have the "aggressive" stance. The instant our scout arrive, they attacked him and he was destroyed. But that's OK, the report stays around forever for us to collect at our leisure (though of course, if you leave it too long, it'll become out of date – the report is a snapshot of what the scout saw when it was there).

So it looks like there's quite a few ships on this star that we'll have to destroy if we want to colonize it. We wouldn't want to send a colony ship there now, because it would just be attacked as soon as it arrived. Scouting, therefore, is quite important because there's no other way to see what fleets an empire has.

Collecting Taxes

If we want to attack the other star, we're going to need a whole bunch of fighters. In the future, you'll be able to purchase ships from the market (assuming other players are selling), but for now we have to build them ourselves. We can kick off a bunch of builds to build a whole heap of fighters:

Building a bunch of fighters

Because we're building so many, we need a lot of minerals. That's why it takes much longer to build these 300 ships than the 50 we built before: this build spends more time waiting for resources. Anyway, once those fighters have been built, we can launch an attack. But now there's another problem:

Too expensive!

With so many ships, the cost to move them is too much! As I mentioned in the last post, one way to get cash is to collect it via taxes, so if we open up the Empire overview, on the colonies tab we can collect taxes:

Our three colonies, with taxes available

Taxes build up slowly over time in the colony. You add them to your global pool of cash by coming here and collecting them every now and then. Select a colony, click "Collect Taxes". Once we have enough cash, we can move our fighters to the enemy's star and begin combat!

Combat

Combat is also something I've started working on. It's at the very early stages at the moment, but so I won't go into too much detail here. Here we are launching our fleet of 670 fighters at the enemy star:

Fighters on the way to the enemy star

Now, once those fighters get to the enemy star, they'll attack the fighters that are there. The rules that govern combat are still being worked on, but I see something like this:

  1. Combat runs in "rounds", one minute each round
  2. At each round, every ship that's attacking fires at exactly the same moment
  3. Damage is calculated after all ships have fired. The amount of damage a ship does is calculated based on it's offensive score and the target's defensive score
  4. When a fleet reaches zero ships, it's destroyed and the attacker will (automatically) choose another target.

The second and third point there are important. Basically, if you and the enemy are equally-matched, then you will both be mutually destroyed. The winner is always the side with the strongest force, it doesn't matter who goes "first".

Also, combat is largely automatic. You send a fleet to an enemy star, and it will choose which target to attack first, which to attack next and so on.

I'll have more details of how this works over the coming weeks, but I'm working hard on building a unit testing framework so that I can ensure combat is properly scoped, speced and tested. It's the most important aspect of the whole game!

Mechanics of combat

Posted by

Combat is probably the most important part of the game. I’ve kind of been avoiding it up until now, because I was afraid of the complexity (and also because there was probably a whole lot of surrounding things that needed to be in place first, for sure) but now it’s pretty much unavoidable. A reasonable combat system is probably the final piece I need in place before the game is ready for Alpha release.

Goals

I have a couple of goals that I want the combat system to reach:

  • It needs to be largely automatic. I don’t want to require that people are actively playing the game for combat to be resolved – you should be able to send your fleet to an enemy star and then come back later when the combat is resolved.
  • It should be reasonably easy to understand. I don’t want to give you too much information on who will win a particular fight, but it should be easy enough – with a bit of experience – to be able to predict the outcome of a fight.
  • You should get enough warning that you’re about to be attacked that you’re able to do something about it.
  • While you don’t have to be present to win a fight, actually being present when the fight is happening should give you at least some advantage (for example, you should be able to run away if it’s too much to win, for example)

I’ve started implementing the combat system already. Here’s what I’ve got so far:

  • Combat runs in rounds.
  • Each round runs for a minute.
  • At each round, every participant in the battle fires their weapon at the same time.
  • After everybody’s fired their weapon, then we calculate the damage done. That means, if you have two equally matched fleets fighting, they’ll fire their weapons at the same time, and mutually destroy each other.

That’s actually about it so far. There’s a number of problems that I need to solve, though, before this is playable. The most glaring issue is that it’s really hard to know what happened after the fact. That is, you send a fleet to a star, something happens and when you go to look, it’s been destroyed, or other fleets have been destroyed, etc.

Combat Reports

To beat that problem, I want to add this idea of a combat report to the game. That is, at the end of each round, a report of exactly what happened in that round is generated. So when you come back to the star later on, you can call up the report and see exactly who killed whom. An example of what that might look like is below:

Round 1
Hunters fleet of Fighter (× 50) entered
Collectors fleet of Fighter (× 175) entered
Hunters fleet of Fighter (× 40) entered
Hunters Fighter (× 50) targets Collectors Fighter (× 175)
Hunters Fighter (× 40) targets Collectors Fighter (× 175)
Collectors Fighter (× 175) targets Hunters Fighter (× 50)
Hunters Fighter (× 50) attacks Collectors Fighter (× 175) for 50 damage
Hunters Fighter (× 40) attacks Collectors Fighter (× 175) for 40 damage
Collectors Fighter (× 175) attacks Hunters Fighter (× 50) for 175 damage
Hunters Fighter (× 50) is hit for 175 damage
Collectors Fighter (× 175) is hit for 90 damage
Hunters Fighter (× 50) is destroyed
Collectors Fighter (× 175) is reduced to 85
Round 2
Collectors Fighter (× 85) targets Hunters Fighter (× 40)
Hunters Fighter (× 40) attacks Collectors Fighter (× 85) for 40 damage
Collectors Fighter (× 85) attacks Hunters Fighter (× 40) for 85 damage
Hunters Fighter (× 40) is hit for 85 damage
Collectors Fighter (× 85) is hit for 40 damage
Hunters Fighter (× 40) is destroyed
Collectors Fighter (× 85) is reduced to 45

So there’s a lot happening there, but basically each round is broken up into 5 “sub” rounds. In the first sub-round, any new fleets are added to the pool. In the second sub-round, any fleet that doesn’t have a target (either because they’re new, or their previous target was just destroyed) selects a target. In the third sub-round, everybody fires on their respective targets. In the fourth round, the actual damage on the fleets is added up. And in the fifth round, fleet size is reduced by the damage amount and the fleet is destroyed if it hit zero ships.

The plan is that when you open up the star, you’ll be able to get that report with all of that detail as required. In this way, you should be able to (over time anyway) get a feel for how the combat will go in advance.

A possible loophole

One possible loophole with the way the combat works as described above is that it’s advantageous to have – say – 100 fleets of one ship each than to have one fleet of 100 ships. The reason is, each round a fleet can only target one other fleet. So if you’ve got 100 fleets against one fleet, then the 100 fleets will all be able to target the one, but the one will one be able to target one at a time.

I’m hoping that the pain of managing 100 separate fleets will somewhat reduce this loophole, but I’m also thinking of maybe introducing some kind of penalty for smaller fleets. For example that maybe the damage a fleet does increases as the size of the fleet increases, or perhaps that the shields are more effective in a larger fleet. I guess play-testing will let us know whether that’s required or not.

Next Time

So that’s where things are today. I’ll be working on all of this in the coming weeks, and hopefully there’ll be some screenshots and maybe even a gameplay video coming up once I’ve got more of this in place.

I’m really excited by the progress we’ve made so far, and I hope to have an alpha version ready for people to try out very soon now.

Thinking about cash

Posted by

Currently, there's two kinds of resources in War Worlds: goods/food and minerals. Food is used to sustain your populations (not enough food and the population in your colonies starts to drop). Minerals are used to build things.

But one of the things I want to add to the game is the ability to trade. One of the things I like about the game Pocket Empires is the global market place where you can go to buy and sell units. It's based off a modelling of a stock market where you bid for items and the price fluctuates as biddings increase or decrease. I really like this idea and would like something similar for War Worlds, but in order to do that I need some kind of global currancy.

Gimme da cash!

Earning Money

The first question, then, is how do you earn money?

Currently, I'm thinking a simple tax on your population will do. That is, each hour (or so) you earn $x per unit of population across all of your colonies. So for example, you might have 4 colonies with 600, 700, 800 and 900 population each. Let's say you earn $0.33 per unit of population per hour. That would mean you get $990 per hour from your colonies.

These numbers are just a rough estimate, of course. In the future I could even make it more complicated like if you're got a "happy" population you'll get more money etc. But for now I think a flat rate is the easiest to understand.

Trading

To actually trade, I imagine something similar to Pocket Legends as I described above. That is, there's a "global" marketplace where you can put up a fleet from your collection for sale at a given price. People put bids in at a certain "buy" price, and trades are made when the prices match up.

To begin with, I can see trading food and minerals as well as ships and possibly buildings.

One problem that I can see is that if you buy ships from another player, how do they get to one of your stars? If they're "instantly" transported from the player's space to your space you could see it as a way to move fleets across space really quickly. So for example, if I want to transport ships between my colonies quickly I could make a sell and then a buy in quick succession to move ships to a different star without actually having to do anything.

Another issue is that if I'm being attacked by another player, I can just buy backup ships in the market and have them appear in my star system immediately. That doesn't seem fair when in reality I should have planned for the attack better.

So I think the obvious solution is that when you buy ships, they appear outside your star system, some distance away and you've got to wait for them to arrive. I think that would solve most of the problems I can think of with an "instantaneous" transfer.

Spending Money

One problem with the above is that money would be added to the universe but never destroyed. Trading simply causes money to change hands, but if money is being made from "nothing" then it needs to go somewhere or you'll just end up with hyper inflation (if you look at food, it is used by populations for sustenance, minerals are used by ships which get destroyed when they fight, etc).

So what I'm thinking is that moving fleets between stars will cost "fuel" (which costs money). So for example, a 20 parsec jump might cost $1 per ship, 100 ships costs $100 and so on.

This has the side benefit of somewhat restricting your ability to expand infinitely. You can't just fly your ships out to the deepest depths of space, because all that fuel is very expensive. Well, it'll still be possible, but hopefully the opportunity cost will make it so that few people will actually bother.

We could also have some ships that are more fuel efficient than others. So it cost less for some ships to move between stars than others. For example, moving a colony ship might be very, very expensive making it more likely that you'll colonize multiple planets within a star system than lots of individual stars. That would also mean you're more likely to "cluster" your colonies among close stars, rather than spread out really far. That could be a good thing or a bad thing, I suppose, depending on what the desired behavior is.

Real Money

So that brings us to the last point, "real" money. I was thinking that the primary in-app purchase would therefore be in-game cash. If you can buy in-game currency with real money, then it would essentially be a short-cut if you can't wait for your colonies to pay their taxes. From what I can see, this kind of in-app purchase is usually pretty common, and I don't think it unfairly advantages players who are willing to spend money over those who aren't (you just have to wait longer).

Conclusion

So that's how I'm thinking cash will work in-game. As with all things, this is all quite subject to changes and tweaks.

Screenshot Saturday, September 2012

Posted by

I'm writing this post as an accompaniment to my "Screenshot Saturday" post over on /r/gamedev. If you've been following along on my blog, you've probably seen most of this already but it's nice to have it all described in one go.

We're going to look at the process of building ships and moving them around. So without further ado, let's get started!

When the game first starts up, we start off in the "starfield" view:

Starfield view, a couple of colonized stars

You can see in this view there's a couple of colonized stars already. Our empire is called "Killerz" (which you can gather from the bottom right) so we have two colonies on star "Baradhrand" and fleets of ships on the other two stars as well. Going into the Baradhrand star system, we get to the solar system view:

Solar system view, Baradhrand I selected

The solar system view shows different kinds of planets (each with their own unique characteristics). For each planet, there can be one colony. The colonies can have different "focus" level for each of "population", "farming", "mining" and "construction". The levels basically control which fraction of the population is dedicated to that particular task (so the more focus you have on construction, for example, the faster you can build).

If we tap on the "focus" button, you can see how you can adjust the values:

Adjusting the focus of a colony

Next, we tap on "Build" to see the build menu. You can build buildings or ships, here's the current list of ships (it's rather sparse, I know):

List of ships you can build

If we want to build a Scout, then we tap on it and a confirmation pops up.

Build confirmation

The confirmation is currently missing a lot of information, such as the actual time it'll take, cost and so on. But you get the idea. Once your scout is building, you can see it on the "Queue" tab:

Queue tab with a bunch of ships in progress

Here we have a bunch of ships in progress. The more ships you're building, the slower each one will take. Essentially, the "focus" of your colony dictates how much population is dedicated to "construction" and then that number is divided between however many things you have in your queue. So if you've got two ships, it'll take twice as long as just one ship and so on.

When construction is complete, if you're away from the game, then you'll get a notification (notifications still need a lot of work in the game. Also, ignore the time on my phone, I cheated a little bit so I didn't have to wait :)

Notification that construction is complete

With the ships built, if you go back to the solar system and click on "Fleet" it'll pop up a list of the ships that are currently in orbit around your star:

Fleet list around Baradhrand

Not all of the features here are working yet, but "Split" works and lets you split a fleet into parts. So we can turn one fleet of 4 ships into two fleets of 2 ships each like so:

Splitting a fleet into two ships each

Moving ships from star to star is obviously how you expand your empire and attack your enemies. To move a fleet, you tap the "Move" button and it pops up a window like this where you can choose the destination:

Moving a fleet to another star

Again, there's a lot of information missing here (such as an indication of how long the fleet will take to arrive, and details about what's already there, etc) but after you tap "move" the fleet will start moving. It takes some time, but you can monitor progress back on the starfield view:

Fleet moving between stars

Selecting the fleet will show you details of where it's going, how long it will take to get there and so on.

Next Time

Work is progressing quite well. Coming up, I want to refine the "colonization" process a bit. Currently, you can just tap an empty planet and colonize it, but the way I want it to work is that you can only do that if you have a colony ship in orbit, and colonizing a planet "destroys" the colony ship. Additionally, there's plenty of tweaks to the UI and so on that needs to happen, and possible also something about attacking enemies as well.