Monday, December 1, 2014

Movement rules updated

Movement points are now reduced according to the hull type of the spaceship. This leads to bigger ships being slower. Also, movement points are no longer calculated in integers, but with decimals. 

Ships may now get for example 2.7 movement points per turn, have 5.8 remaining movement points and a maximum of 11.7 points.
I used the opportunity to refactor the Ships database table and remove the spatial data types from it.


The feature list for the next game got two new items:


The ranking will calculate the rank depending on population, research, goods and so on.
I am ambivalent about this feature. On the one hand I don't like it, because it is an artificial competition which should not be needed. On the other hand, I heard multiple complaints about this feature missing in the game, and, frankly, this artificial competition does indeed trigger some kind of “I just want to catch up with the next guy in the ranking” feeling, which can be fun.

The second task, the ending scenario, is a big one. But as soon as that is implemented, this game reaches beta status.
There will be multiple ending scenarios later, but for now the “Ascension” scenario will suffice:

Ascension

As soon as one player has the needed research, he can begin with the construction of a special space station, the Ascension Construct. Completion of the space station will trigger galaxy-wide Ascension – which ends the game.
The construction of the Ascension Construct will need so many resources that a single player will not be able to do this on his own. His alliance, and possibly other alliances as well, will help constructing it.

All the while other player/alliances may start their own Ascension Constructs, hoping to win the race themselves.

When the first such construct is finished, all players gain victory points according to several factors:
- Their contribution to the winning Ascension Construct
- Distance of their homeworld to the construct
- Ownership of the construct. membership of the alliance owning it, being allied with the owners
- the normal ranking points will probably also count as victory points



Wednesday, November 26, 2014

New Research: Fleet Command





Fleet points define how big your fleet can be without costing any upkeep.
You start with 25 fleet command points. Each ship uses as many points as it has places for ship modules (scout 5, corvette 7 …).
The new researches give you additional command points, but reduce your overall productivity.
If your fleet uses more command points than available (25 + fleet command research), upkeep costs will occur. Upkeep does also lower the productivity of the colonies.
The ship list shows the current values:







The formula for the upkeep is:

( shipPoints – commandPoints ) / commandPoints

and the result is capped to a value between 0 and 1.
Here is an example:

6 scouts = 30 ship points
Base command points and no research = 25 command points

(30 – 25) / 25 = 0.2 => 20% Upkeep

Which would mean a loss of 20% on each produced good.
Aside from the upkeep constraint, empires can't build more ships than twice their command points.

Some benefits of the new feature:
  • Since fleet size is restricted, fleet quality becomes very interesting. The strongest spaceships are built of ship modules made of special resources. Since each region does yield only one of the five special resources, most empires will have access to only one or two types. Trading with other players will get you these resources (or ship modules made of these).
  • Everyone has to live with the fleet command constraint, and those who handle it best will have an advantage
  • When empires build huge fleets during a conflict, their economy will take harm
  • Wars won't be fought in a day anymore. During conflicts, the previously accumulated goods will be spent over multiple days, perhaps even weeks.
This new feature will not be merged in the currently running game or demos, but the next game will include it.
If you think the implementation should be simpler / more complex / completely different - just specify it in a comment, and I will take it into account and possibly change the implementation.









Monday, November 17, 2014

Progress on the new game server

The progress is slow, but at least steady.
The new game server is in its final testing stage. As soon as that is done, new features will be added to the game.
The whole server thing means a huge change in game architecture. But this new version will be more suitable to serve hundreds of players simultaneously.

The current game does not implement this technique - it does distinguish from the previous alpha game in map size an the newly added colony limit.

Saturday, October 25, 2014

Three Tier Architecture Sample in C#


The short version:

Uploaded a simple C# sample solution (Visual Studio 2012), featuring:


  • 3 tier architecture (web application, web server, database)
  • AJAX calls from a web application
  • XMLSerialization
  • Accessing a Database with SqlDataReader
  • layer architecture of the server tier (business connector, data connector and core)


The long version:

Lately I made some changes to the client server architecture. The original design consisted of a big client (javascript running in the browser), a very small web server and a lot of SQL.
I put most of the business logic into sql because I thought that transaction handling, concurrency and scaling would be easy to implement with sql. The use of spatial data types seemed also to simple some things which would otherwise be programmed by hand.
Additionally, I wanted to find out if it is possible to write all of the server sided code in sql.
And finally, I just like sql programming and wanted to write more code in it.

Until recently, the program flow was as follows: 
The web server remembers user id per user in a session cookie. The server receivers ajax requests, calls a sql stored procedures with the client parameters and the user id and returns the result of the stored procedure.

Mostly, this implementation worked just fine, but as reported in the last blog, I ran upon a performance problem regarding spatial indices. Subsequently, I added a programmed game server to the game architecture.
The web server now receives user requests, but does not call the stored procedure but a method of the game server.

The game server consists of the following namespaces:
BC (business connector)
Core
DataConnectors

The following requirements should be fulfilled by the server tier :
- The business connector should be the only one accessible from the outside. It reveals a bunch of methods.
- Classes in the core contain the game data and do all the processing.
- The data connector is called when the core needs data or to writes updates 
- The game server has to be designed in a way that it may grow to many thousands lines of code in 100+ classes, without getting a big unstructured mess (source code tends to rot if you are not careful).

The last point is the one for which I didn't find good advice or examples. That is the reason why I put a tidied up version of the game server on github. Keep in mind that I have until now programmed only few features in the game server, so I can't guarantee that its design is as good as hoped.

This is a typical workflow for a web server request: 

  1. calling the bc method in BusinessConectort.cs file 
  2. creating an instance of the corresponding bc class which3
  3. creates an instance of a core class doing the work
  4. the core class 
    1. fetches data into sql table corresponding objects
    2. does the calculations
    3. writes back to sql
  5. the bc class then generates the output
I do not momentarily need a sophisticated way of communication between the web server and the game server. Thus the current solution is a dll which lets the web server instantiate the business connector. A better solution in the long term would be a stand alone server. That server could then even communicate with multiple web servers.

That only the business connector is accessible from the outside is not yet fully implemented. Some classes have "internal" as access modifier, preventing outside access.Others had to be set as public, since I wanted to use them with the XMLSerializer.

The web application project is kept very simple. The ajax return is imply inserted into the dom. Either adapt the result of the business connector, or add some javascript logic to parse the result, if you are implementing a web application yourself. Or do both, returning a json string from the server and creating a javascript object from it would be a good beginning.

I would be happy to hear suggestions or get even improvements to the sample.

If you like it, and in case that you also like multiplayer 4X games, check out Empires in Space, the reason for writing the game server...










Monday, October 20, 2014

Performance Problem (SQL) and its (ongoing) Solution

During the end phase of the second alpha test, one of the players informed me that logging in to the game took about 10 seconds for him.

The reason for this lied in a sql query which performed bad.
If you are interested in this technical details, you can read the corresponding question on stackoverflow. You may even reproduce the problem with the source code posted there. 

There seems to be no way to get the query running fast enough for the game, so I decided to calculate the required data in the game server tier instead of the sql server tier.
That is what I am programming at the moment.

Next post will be about the architecture of the server tier. I will probably even put a sample project (C#) on the github account of Empires in Space.

Saturday, October 18, 2014

Empires in Space is now in Open Alpha Phase

A New Massive Multiplayer Online 4X Computer Game

Empires in Space is like all classic 4X strategy games, but in addition to the standard features of the genre it is designed be a massive multiplayer online game.

  • all the standard features of normally installed 4X games now online
  • play with friend without needing them to be online
  • compete with human beings: all other realms are player controlled (and not AI)
  • there is no pay to win and never will
  • strategic cooperation with friends – defend (or expand) the borders of your realms together
  • ally yourself with your friends instead of fighting them – there will be enough opponents against who it would be better to stand as a group


Here are two playable online demos (no login or registration required):
Demo Starting Phase
Demo Advanced Phase

This is what the Alpha Version looks like at the moment. The screenshot shows a solar system, where your colonizer space ship arrives at the beginning of the game.



This screenshot shows the star map later in the game, when you have discovered a large area and met multiple other nations:



The game does run continuously on a server, without the need for a player to log in.
The idea is that multiple turns are played per day but all benefits of the turns stack up, so that you don't have to get online after each turn. Depending on the game settings, there are up to six turns a day. Only the movement points will be capped after having added up for five turns.
The most important tasks may be done within five minutes per day, but of course a player may spend more time on scouting, diplomacy and trade.

These features are implemented up to now:
  • ship movement, combat and colonization of new worlds
  • colony management, small chains of productions
  • research
  • ship designer to create unit templates, and ship building
  • alliances (clans)
  • diplomacy
  • local communication networks (generic ones and new ones from players themselves)
  • trade between players
The game ends shortly after the research tree is fully explored and the players should be able to influence the ending scenario.
Since it is a massively multiplayer game, there are some problems with ending scenarios that affect all players. The typical scenario would be “Conquest”, which would mean that a lot of players actually lose the game.
The ending scenarios are not implemented yet. The first one to come will be “Research” which leads to a global “Ascension”: After having researched the technology, players may start an “Ascension Construct“ or help to build another players construct (and of course try to destroy rival constructs). The first such construct to be finished will end the game, and players will get points according to their contribution to the construct, their spatial distance to the construct, their population and possibly other factors.
As long as there is no ending scenario, players can simply enjoy themselves by exploring, colonizing, exterminating, bartering and negotiating for fun.

You can find the project's homepage here, feel free to join the current game. I will enable turn progress as soon as ten players are part of the game.
Game content and game mechanics may be discussed in the forum, e.g. how to prevent a blitzkrieg.


I am looking forward to hearing from you, learn about your ideas, your wishes about content or your recommendations on changes.