Sunday, November 12, 2017

Cosmoteer 0.13.0 - Multiplayer!!!

Given the lack of updates for the past couple of months, you'd be forgiven for thinking that I had stopped working on Cosmoteer. Thankfully, you could not be more mistaken!

I've actually been working on one of the biggest new features in the history of Cosmoteer: Multiplayer!

Those of you who have been following Cosmoteer for a really long time probably know that the original prototype versions had support for multiplayer in which players could design ships and battle them with their friends. But I realized that having to support multiplayer was dramatically slowing down the development of Cosmoteer, including development of singleplayer-only features. And so I removed multiplayer support from the game's code, hoping (but not expecting) that one day I would be able to bring it back.

Well, that day has arrived! I am incredibly proud and excited to announce that multiplayer is returning to Cosmoteer!

In this first version, multiplayer is a simple team-versus-team battle of up to 8 players spread across two teams. Each team has a certain amount of money (configured by the host) to spend on a fleet of up to 5 ships per player (or fewer, as configured by the host). Then the game starts and the players control their own ships, attempting to destroy the other team's fleet. The game ends and one team is declared the winner when either the other team's fleet is sufficiently destroyed or the timer runs out.


You can play with anyone on the same LAN (Local Area Network) as you, and you can also play with a friend anywhere else in the world by typing in the host computer's I.P. address. (There is not yet a public online list of games, but I hope to add that soon.)


This is just the beginning! This first version lays the coding foundation for more improvements to come. In the long term, I may add entirely different game modes, such as multiplayer co-op and creative modes. In the near future, I plan to add:
  • A.I. players in multiplayer battles
  • Observers (for streaming tournaments)
  • More than two teams & free-for-all battles
  • Some sort of boundary around the playing area to prevent people from being able to run away indefinitely
  • Limit price per-ship and not just total price per fleet
There's lots more details and plenty of other fixes and improvements in the full changelog.

Technical Implementation

You may be wondering why I've chosen to bring back multiplayer given the fact that I originally removed it because it was slowing down development too much. Wouldn't bringing back multiplayer cause all future development to become a lot slower?

Thankfully, the answer to that is mostly "no", and the reason for that is that I've taken an entirely different approach to implementing the multiplayer code.

The original implementation of the multiplayer code required that every single change in the state of the game (such as a ship firing a weapon, a ship moving a millimeter, a crew person walking a foot, or a bullet hitting an enemy) be synchronized among all players by sending packets over the internet. This was a huge problem for two very important reasons:
  1. In a game as complex as Cosmoteer with potentially dozens of ships and thousands of crew, that's a potentially huge amount data that needs to be transferred over the internet between all the players. We're talking megabytes per second of data for a large battle, which made the game really only playable on LAN or very-high-speed internet connections.
  2. The code for anything that could affect gameplay even in the slightest became way more complicated due to the need to send those aforementioned internet packets. For example, if I wanted a bullet to inflict 1000 damage on an enemy ship, I couldn't just call the TakeDamage(1000) function; I first had to construct a network packet with all the needed information and send it to all other players. This made working on gameplay code far more time-consuming that it would've been without having to send all those packets.
The new multiplayer code uses an entirely different approach that's called "deterministic lockstep". Essentially, this approach requires that two computers running the same version of the game with the same initial battle setup and same player inputs will simulate the game in exactly the same way. (Not even off by a millimeter, or else the butterfly effect will cause bigger and bigger errors until the game desyncs.) There are two big advantages to using deterministic lockstep:
  1. Only player inputs (commands issued to the ship) need to be turned into packets and sent over the internet. Everything else (physics, weapons, damage, etc...) will happen exactly the same way on every computer by virtue of them running completely deterministic game simulations. This saves massively on bandwidth, so much so that Cosmoteer now only uses a few KB of bandwidth per second.
  2. Code that affects gameplay no longer needs to be synchronized using packets sent over the internet, so long as the gameplay code can be written to be 100% deterministic. Writing deterministic gameplay code isn't very hard as long as you know what kinds of things to avoid (primarily code whose outcome could change based on framerate).
There are, however, some important disadvantages to using deterministic lockstep:
  1. The gameplay really does have to be 100% deterministic. 99% deterministic is not good enough. And non-determinism bugs can be very tricky to track down. I have written myself some pretty nice tools for debugging determinism issues, but it still took me several weeks to comb through the whole Cosmoteer codebase and convert everything to be deterministic.
  2. Games that use deterministic lockstep typically have more latency than other types of games. You may notice that when playing multiplayer Cosmoteer (and most RTS games) that there's a small delay after assigning a ship an order and before you see it actually respond. That's because it has to wait for the other computers to receive the order before it can process it. In action games like first-person-shooters, this would be a huge problem, but in slower games like Cosmoteer, it's not a big issue.
  3. Differences in how different CPUs compute floating-point (fractional) numbers can cause an otherwise 100% deterministic simulation to become only 99% deterministic, which due to the butterfly effect will ultimately lead to desyncs. In practice, this means that players running on 64-bit operating systems can't play with players on 32-bit operating systems. (Although there is a mode to force the game into 32-bits so that friends on different operating systems can play with each other.)
While these downsides are significant, none of them are deal-breaking, and are certainly preferable than the problems caused by the original way I implemented the multiplayer code.

All in all, getting multiplayer working again was a pretty huge undertaking -- one that I wasn't even sure I could pull off -- but in the end I think it has proven to be well worth it. And I'm looking forward to playing a ton of Cosmoteer multiplayer as a result!

Tuesday, September 19, 2017

Cosmoteer 0.12.12 - Balance improvements and bug fixes

Cosmoteer 0.12.12 is out! And while it's not as huge as 0.12.11 or 0.12.10, it's still got some nice stuff in it. Specifically, thanks to some great work by the community crunching some numbers, I have done a pass over all of the weapons to adjust their damage, rate of fire, and ammo usage, to make them more balanced. (Standard Cannons are no longer the clear best weapon as measured by DPS.) There's also a bunch of other improvements and bug fixes, which you can read about in the changelog.

Monday, September 11, 2017

Cosmoteer 0.12.11 - Difficulty levels, new game options, and balance changes

Cosmoteer 0.12.11 is out! And if you thought that 0.12.10 had a lot of improvements, then you will not be disappointed by 0.12.11!

The biggest and most obvious improvement can be seen when starting a new game:


When starting a new Bounty Hunter game, you are now given several options to customize your play experience...

First up, there are three difficulty levels that you can choose from: "Ensign" (easy), "Captain" (standard), and "Admiral" (hard). Each difficulty level affects what kinds of enemy ships spawn, the intelligence of their A.I., how much money you start the game with, and how much money you earn as a reward for destroying enemies. The "Captain" difficulty is the closest to the single difficulty level that's been available until now.

Second, you can also customize the size of the galaxy, which simply determines how many solar systems will be in it. "Standard" is the closest to the single size that was available until now, but you can play with a huge galaxy if you want a really long game or a small galaxy if you want a shorter experience.

And lastly, you can now choose between three different starting ships, each with its own advantages and disadvantages. Or if you don't like any of them, you can even start the game with your own design. The amount of funds you'll start the game with will depend on how expensive your starting ship is -- the more expensive it is, the fewer funds you'll start the game with.

Another big change to Bounty Hunter is the presence of enemy "fleets". Now, in some cases when a single enemy would have spawned in older versions, in 0.12.11 that single enemy will be replaced with 2 or more smaller enemies that will work together as a single fleet. This means that you'll have to design your own ship(s) to be able to combat multiple enemies at once. The chance of enemy fleets spawning depends on the difficulty level selected.

This update also has a ton of big balance changes that I hope will make ship design more strategic. These include a nerf to Point Defenses (to make them less effective versus swarms of missiles), an area-of-effect buff to missiles themselves (to make them a possible counter against parts placed directly in front of shield generators), cannons now have a random "spread" (to make them less effective at sniping specific enemy parts), and Electro-Bolts can now penetrate through shields (meaning they can drain from multiple overlapping shields).

Lastly, players complained a lot about how moving parts of ships to different locations cost money to move, and so I made a change that allows you to move a part from one location to another without losing any money. Basically, if you pick up or remove a part, you'll only get a 75% refund, but then if you place the same kind of part somewhere else, you'll only pay 75% of the base cost. Once your ship fights a battle or makes an FTL jump, you'll lose the 25% discount for any parts you've removed but not re-added and you'll have to pay the full 100% price.

There are a whole ton of other improvements and bug fixes in this update, which you can read about in the changelog.

Wednesday, August 16, 2017

Cosmoteer 0.12.10 - Formations

Cosmoteer 0.12.10 is out! And it has a pretty nice new feature: Formations!

When multiple ships are selected, a new "Formations" button will appear, and clicking on it will let you pick from one of three pre-defined formations: Line, Wedge, and Claw.


Additionally, you can create your own formations by selecting a ship, right-clicking on another ship it should follow, holding the mouse button, and dragging the mouse cursor to where the selected ship should position itself relative to the "lead" ship. You can then save the custom formation to be used later.


And by default, when you issue a command to a group of ships that aren't already in formation, the game will automatically create an "ad hoc" formation, causing the ships to stay in their same relative positions and move at the same speed.

This update has a huge number of other improvements and fixes (possibly the largest number of individual changes in the history of Cosmoteer updates), which you can read about in the detailed changelog.

Wednesday, July 26, 2017

Cosmoteer 0.12.9 - A ton of bug fixes!

These past few weeks have seen an absolutely massive increase in the number of people playing Cosmoteer! There used to be less than a hundred players per day, but now there are more than ten thousand! That's amazing!

What's not so amazing are all the bugs that people are now finding in the game. (It turns out that when ten thousand people play your game, they find all the bugs...)

And so I present to you Cosmoteer version 0.12.9, which is just chock full of fixes for many of those bugs that people have found in the past couple of weeks.

Also, the number of bugs that have been caused by new updates has convinced me that from now on I should do more testing before I release updates to everyone. To that end, I am planning, for most updates, to first release what I'm calling "unstable release candidates" that any interested players can opt-in to playing, with the understanding that these unstable versions are likely to be more buggy than the "official" stable updates. As 0.12.9 you can opt-in to unstable updates in the settings under the "Misc" tab. Hopefully this extra testing by the community will make the official updates much more stable.

Sunday, July 16, 2017

Cosmoteer 0.12.8 - Bug fixed and balance tweaks

Cosmoteer 0.12.8 is out! This update has a ton of important bug fixes, but it also makes a few balance changes, including making FTL jumps use less fuel and reducing the effectiveness of Electro-Bolts. You can read the full changelog here.

Tuesday, July 11, 2017

Cosmoteer 0.12.7

Cosmoteer 0.12.7 has been released with a variety of unrelated improvements.

The most important change that everyone should know about is that the location in which saved games and ships are stored has been moved from Saved Games\Cosmoteer (the old location) to Documents\My Games\Cosmoteer (the new location). I made this change because some players for some reason didn't have a Saved Games folder on their computer and thus were unable to play the game. When you run Cosmoteer for the first time after updating to 0.12.7, the game will attempt to automatically move all of your existing saved games and ships to the new location, but if that fails for some reason then you'll have to move them manually.

0.12.7 also has a few balance changes, most notably being a "fix" to a deliberate flaw in the ship A.I. that prevented it from properly staying at the desired distance from the enemy. This has the effect of making "kiter" ships (ships with long-range weapons like missiles and a lot of reverse thrust) much more viable. I'm not sure that's actually a good thing for the game's current balance, but the proper counter to kiters certainly should not be a gimped A.I. (I'm considering adding tractor beams as a way of countering fast ships.)

Lastly, I have paid off the "internet mafia" (my word, not theirs) to get what's called a "digital signing certificate" that I can use to "prove" to Windows that I, a real person named Walter Destler, am the author of Cosmoteer. So now, when you run the installer, you'll get a dialog prompt that looks something like this:


The real reason for doing this is that, in theory, anti-virus programs are more trusting of applications that have digital signatures. I'm hoping this will reduce the number of problems that overly-aggressive anti-virus programs cause with Cosmoteer. Only time will tell!