Design & Concepts

* The Layer Architecture

We have decided to implement the program following a two-layer model. There will be a core layer, encapsulating and modelling the state of the game. This core layer will be accessed by game layer, which is responible for playing the game, i.e., it will receive information and give commands to the core layer via a well-defined interface.

The Orion Core Layer (aka API)

This layer contains the data structures representing the whole Free Orion universe, containing information about all the stars and planets, ships, etc., and also the players and their interrelations. These data structures are supplemented with basic methods for their management, which are not transparent to the actual game-play. General functions like the code evaluating the turn commands (see The Turn Concept) are located in this layer as well. More concepts of the core layer will be discussed in the sections API Concepts and API Requirements.

Implementation: The core layer will be implemented in the java package org.freeorion.api. Its central class is the Controller, which gives access to all other relevant objects within the core layer. The objects of the core layer will provide methods to access the relevant data and to manipulate the objects of the core layer according to the rules of the game.

The Game Layer

There will be different kinds of game layers:

Implementation: A class claims to be a game layer by implementing the org.freeorion.api.GameLayer interface. We assume that the classes of the game layer are not part of the org.freeorion.api package, instead they form a seperate package of their own. So the GUI is implemented in the package org.freeorion.gui and a computer player driven by artificial stupidity may be placed in a package like org.freeorion.stupid.

* Client and Server

Free Orion is a game to be played by multiple players (real players via a graphical interface or computer driven players). Each player has her own restricted view on the world. We respond to this request by assigning to each player a personalized restricted copy of the core engine. This copy will be call a Free Orion Client (realized be the class ClientController).

On the other hand there will be one central instance of the core engine, containing an (unrestricted) view of the whole world. This core engine will be called the Free Orion Server (implemented as class ServerController).

*The Turn Concept

Free Orion is a turn-based game. Each player can perform a (theoretically unlimited ;-)) number of actions in each turn. Turns of differrent players are assumed to happen simultaneously, so one player should not be aware of the effects of another player's actions before the beginning of the next turn. This means that the evaluation of the players' actions needs to be delayed.

This requirement is answered by the Client and Server concept and a mechanism called the turn command list: During a turn the player will manipulate her world, that is she will send commands to the client assigned to her. The client will execute the commands, but it will also collect them in the turn command list. When all players have finished their turns, all the clients will send their turn command lists to the server which will evaluate them. The server then has an up-to-date picture of the universe and will send this to the clients.

*The State Concept

Each turn can be divided up into different phases or states. These states determine what kinds of actions are valid at that time. We have two sets of states, one for the client and one for the server:

The client cycles through the following states:

  1. INIT: The client accepts initialization commands from the server.
  2. READY_TO_START: The client has been initialized and is waiting for a "start turn" command from the server.
  3. RUNNING: The client accepts input from the game layer. This state is terminated when the "end turn" command is sent by the game layer.
  4. FINISHED_TURN: The client has finished its turn and is ready to send the turn command list to the server.

On the other hand, the server knows the following states:

  1. INIT: The server is initializing.
  2. SENDING_TURN_DATA: The server is sending turn data to the clients.
  3. WAITING: The server is waiting for all clients to finish their turns.
  4. RUNNING: The server receives the turn command lists from the clients and executes them.
  5. END_OF_TURN_ACTION: The server performs end of turn actions (see Turn Evaluation).

Implementation: The current state of a Controller can be accessed by its getStatus()-method.

*API Concepts

In this section we collect some concepts that do not fit in any other section of this document.

Objects IDs

Most of the classes in the org.freeorion.api package are derived from org.freeorion.api.OrionObject. The instances of those classes have a unique ID, by which they can be identified, and a reference to the Controller to which the are assigned. While the objects of a client may change from turn to turn, their IDs will never change. [FIXME: So if a game layer wants to store objects to access them in the next turn the objects IDs!]

Accessibility Checks

The classes and methods provided by the API can be divided into public and internal ones. The public methods can be accessed by an (external) GameLayer. This implies that they have to provide protection against misuse. Internal methods are only invoked by other parts of the API. They are local to the org.freeorion.api package and their names are syntactically marked by a leading underscore (example: Ship._move()).

Most of the (public) methods should only be used in certain stages during program execution. The Controller provides a status that can be used to decide if the invocation of a method is valid or not (see The State Concept).

*API Requirements

This section lists requirements we expect the API to implement before we may see it as completed.

Turn commands

In what follows, we give a list of all commands the API should provide to a game layer. Most of these actions can only be performed if some condition is fulfilled. The API must check check these restrictions before it can accept the action to be performed.

However, there are some user actions which we consider not to affect the turn command list. They should be handeled internally by the game layer:

Turn Evaluation

FIXME: This section is not in a sane state yet, so you should better ignore it!

When all the players have put together their turn command lists the orion core engine will start the evaluation. This will be done performing the following steps:

  1. Destroy freighters: Should be performed before they are used (move colonist, food)
  2. Move colonist: This should be done before food, production and research is evaluated, because it affects their actual values. Also the colonists should be moved before a colony is transfered to another player or attacked by enemies.
  3. Transfer colonies and technologies (based on diplomatic actions) This will cancel the actual production, so it should be done before (XXX or after?) the production is performed.
  4. Perform production and research: This should be done simultaneously because new technology should not affect the speed of production and new buildings should not affect the research in this turn. However it should be done before food consumption and combat, so that new achievements can be used there.
  5. Calculate food production/consumption: Should be done before the population growth is calculated. But it may be done after new buildings/freighters are produced so that the player can benefit from them.
  6. Do population growth:
  7. Move ships: The ships have to be moved before the combat check is performed.
  8. Check for combats: In situations where combats are possible, the combatants have to be asked if they wish to fight (user interaction). If a combat takes place this may be the source of a bundle of further actions:
  9. Set ships' destination: Ships which are outside the (new) range of a player should be sent to the next star were the player is present.
  10. Do spying: Should be done after combat.
  11. Calculate money:
  12. Create random events

created on 2001-07-18
last changes on 2003-03-01
contact: webmaster
please do also visit our project status page
hosted by SourceForge Logo