Pre-Order the Game!

Desura Digital Distribution

Monday, December 27, 2010

Small update

I squashed several bugs and refactored some of the old code so it's more clean and easy to fix if any problems pop up.

I've decided to change from random 6 planets per star system to user defined amount. At the new game screen, there are two new options. They are Minimum Planets and Maximum Planets per star system.

By default this is 0 minimum (no planets at all) to 6 maximum. You can change it to be 1 minimum and 1 maximum, and every star system will have only one planet (aka MoO 1, except for some system having no planets. With only 1 planet, the generator will populate only half of the stars with a planet if the minimum is set to 0), or you could change it to 0 minimum and 5 maximum (aka MoO 2)

The maximum "Maximum" value is 100, and minimum cannot be higher than the maximum amount, but can be equal if you want to force equal amount of planets per system.

100 planets per system may be a bit excessive, but I don't want to force limits on some players who want more than 6 planets per system. My goal is to give more choices to the players, so they can try many different scenarios, therby increasing the replayability of the game.

Currently I'm working on scrollbar class, so the players can scroll through research items, construction items, etc. When that's done, I'll focus on the galaxy screen and start implementing fleet movement and exploration.

Wednesday, December 22, 2010

Optimizations, Empires, and Exploration, oh my!

The galaxy generation code bothered me a bit. In a previous post, I talked about optimizing it so it's somewhat faster. But if I do 800x800 random galaxy, it takes my computer over a minute to generate the galaxy (it's a quad core with 4 gig of memory), and there were only like 4,000 stars when it was done. Surely my computer can place 4,000 stars randomly faster than that, so I brainstormed for a faster algorithm. Then it hit me, I can use the quadtree concept I used for galaxy drawing to generate the galaxy. Here's how it works:

Parent node encompass the whole galaxy, and have subnodes that divide the galaxy. This continue to branch until each node are only 1x1 in size. I then tell it to remove nodes that are in illegal areas (for shaped galaxies). Then I tell it to randomly find a node and give me its location. After getting the node, I place a star there, then remove the adjacent nodes. This continue until there's no more nodes.

The end result? The same 800x800 random galaxy that took over a minute to generate now generates it in about 2 1/2 seconds! This is a major optimization! As a result, I'm satisified with how it works, and its speed. I seriously doubt anyone will play in those huge galaxies, but just in case they do, they won't laugh at my generation code.

I've started importing some stuff from the old code (before I started refactoring the whole thing), and did some code improvements and cleaning up. Planets are back in, and each star system can have up to 6 planets. The "IsExplored" is added, and the function "SetHomeworld" is implemented. Starting a game from the new game screen now creates homeworld for each of the player.

I also added an EmpireManager that will manage all the empires. When a player hits end turn, Empire Manager will iterate through each empire, and if it's computer player, execute the AI code, otherwise halt and let the next human player play. When all empires are done, then end of turn will commence. There's no "End Turn" yet, but the Empire Manager will help organize the code for me.

The exploration functionality is there, so when you start a new game, you only see your own home system's name. All other stars don't have their names displayed.

Now that my goals as stated in previous post are accomplished, my tasks now are to import all the old code and re-implement them in the new code. This includes colonization, exploration, fleet stuff, end of turn processing, and other stuff. When those are done, you'll be able to start a new game, select the galaxy shape/size, select players, and start it, then explore/colonize. I might throw in planetary development, but no promises!

Thursday, December 16, 2010

Still working on it!

Sorry about lack of updates. Things kept me busy, mostly me getting sick :( But I've become better.

I've worked on the game, and it now transition between different screens (clicking on new game takes you to new game screen). I also modified the player options. Instead of having three dropdown menus per row, I combined two (human/computer and difficulty) into one, so it looks like this:

Computer - Simple
Computer - Easy
Computer - Medium
Compuer - Hard
Computer - Impossible

One thing to note, it's possible to have more than one human in the list of races, which allows for hot seat multiplayer, or for you to control two or more races. Or you could even have only yourself in the galaxy (for testing an expansion strategy perhaps?).

I've also optimized the galaxy generation code so it creates a new galaxy a lot faster (about 1/28th the time it took previously). But it can still be optimized more, I may look into methods for that. But for now, it can generate a galaxy with about 2,000 stars in less than 5 seconds. I doubt anyone would play a galaxy that huge, but the option is there if they do want to.

I'm currently working on the galaxy screen, and optimizing the drawing process (I don't want to iterate through all 2,000 stars if I'm zoomed in and can only see 4 or 5 stars). I've discovered a method that will help speed up the process, which is the quadtree. It's kinda like a binary tree, but with 4 children per node. I'm also working on the galaxy setup when you click on "Start" after setting up the new game options, it populate the galaxy with races that you've selected.

After those are done, I'll re-import the old code I had before I started the whole refactoring process, which includes colonizing planets, fleet movement, planetary management, population migration, empire income/expenses, ship construction, exploration, supply range (fuel range) and maybe some other stuff that I forgot. Then I'll release that version for testing!