RolePlayingDesign: Difference between revisions
Content deleted Content added
No edit summary |
imported>Hendrik Brummermann No edit summary |
||
| (122 intermediate revisions by 5 users not shown) | |||
Line 1:
{{Navigation for Marauroa Top|Internals}}
It is perhaps the most complex part of all the middleware that compromises Arianne.<br>▼
{{Navigation for Marauroa Developers}}
Role Playing Design determines how ''easy'' is to create a new game for Arianne. We had to choose easing the creation of turn time limited based games, so Arianne will work better with that kind of games, also known as realtime games.▼
Role Playing Desing anyway tries to keep generic and game agnostic.▼
▲
▲Role Playing Design
▲Role Playing
The very basic idea behind RPManager is:
<pre>
Line 14 ⟶ 18:
To achieve this we use several classes:
* RPManager
* IRPRuleProcessor is the interface that you need to
* RPWorld
* IRPZone is
=RPManager=
The goal of the RP Manager is to handle the
* run RPActions from clients
* manage RPWorld
Line 27 ⟶ 31:
* control AI
RPManager
* <i>addRPAction</i> <br>
* <i>getRPObject</i> <br>
* <i>onInit Player</i>
* <i>onExit Player</i><br>
* <i>transferContent</i><br>
The main
<pre>
forever
Line 57 ⟶ 61:
RPRuleProcessor is a wrapper class for actions code and initialization and exit code. <br>
All the actions code MUST be here.<br>
By implementing RPRuleProcessor you personalize Marauroa to
=Objects and Actions=
The whole Marauroa system is managed by two main entities, RPAction and RPObject.
==
Attributes is a collection of pairs of values in the form name-value.
We can store almost any basic type in a Attribute object:
* strings
Line 70 ⟶ 74:
* boolean
We can't store
==Objects==
Mandatory Object Attributes: id, type and zoneid
id is an unique identification for the Object
An id is only unique inside the zone which contains that object.
- Attributes that begin with ! are completely hidden
- Attributes that begin with # are completely hidden for all
===Classes of Objects Explained===
Classes of Objects are the basic way of structuring Marauroa data structures.
The data types available are:
Line 99 ⟶ 103:
* Flag ( it is a binary attribute )
Attributes can
===Slots===
To have
For example
and we can store objects
Once
As attributes, slots
* Slots names that start with ! are only sent to owner player. (Hence only seen by the owner)
* Slots names that start with # are not sent to players. (Invisible to all)
==Actions==
To express the
An action is composed of several attributes
There are optional and mandatory attributes. If a mandatory attribute is not found, the message is skipped by the RPServerManager.
Mandatory
The action_id is used to identify the action when a resulting response comes in a perception
=Perceptions=
The basic structure for sending world updates to clients is called perceptions.
There are two types of perception:
= How Perceptions and Actions work =▼
* Sync perceptions: these are used to synchronize clients with the server world representation. This is the only valid way of knowing world's status.
Actions are sent from client to server in order to make their character to do an action. In order for the client to know the result of the action Server need to send it to client. How?▼
* Delta perception: this is used to send only the changes to the world since the last perception.
Our actual Perception system is called Delta<sup>2</sup>. It is heavily attached to the Marauroa core, so I recommend you to use it :)
On a first try, we used to send client back an action that was the result, but make code really hard because we had to update to different things, perceptions and actions, so the idea appeared intuitively: Why not join action reply and perceptions.▼
▲== How Perceptions and Actions work ==
So the action reply is stored inside each object (that executed the action ) with a set of attributes that determine the action return status and the attributes. This way of working make a bit harder to RPManager but it simplify a lot the creation of new clients.▼
▲Actions are sent from the client to the server in order to make
▲
See Actions reply in Objects document to know exactly what is returned, but keep in mind that it depends of each particular game.▼
▲So the action reply is stored inside each object (that executed the action ) with a set of attributes that determine the action return status and the attributes. This way of
=Delta<sup>2</sup> perception Algorithm=▼
The main idea behind the DPA is not to send ALL the objects to client, but only those that has been modified.▼
▲See Actions reply in the Objects
Imagine that we have 1000 objects, and only O1 and O505 are active objects that are modified each turn. Ok?▼
▲==Delta<sup>2</sup> perception Algorithm==
Traditional method:▼
▲The
▲Imagine that we have 1000 objects, and only O1 and O505 are active objects that are modified each turn.
▲The Traditional method:
<pre>
- Get objects that our player should see ( 1000 objects )
Line 158 ⟶ 170:
</pre>
I hope you see the problem...
The delta perception algorithm:
Line 175 ⟶ 187:
</pre>
The next step
The delta<sup>2</sup> algorithm is based on four containers:
Line 184 ⟶ 196:
* List of deleted objects
An area
To make perception works it is important to call the modify method on RPZone so this way objects modified are stored in the modified list.▼
▲To make
=Zones and Worlds=
Worlds in Marauroa can be so big, so huge, that we need to split them in to several pieces.
Objects must be stored somewhere, and we use Zones now to store them. A zone is just a container of Objects.▼
Each of these pieces are what we call an RPZone.
So our world is made of several RPZones that are '''independent''' of each other.
In order to improve the modifiability of the Marauroa platform we have made RPZone to be an interface so that if you want you can implement it as you think it is more efficient.▼
To move from one RPZone to another RPZone you have to code the correct behaviour in RPRuleProcessor. Just look at any of our coded examples.
==RPWorld==
The actual Marauroa RP Zone consists of several data structures:▼
As we have already said, RPWorld stores several RPZones that are independent of each other.<br>
RPWorld provides onInit and onFinish methods that are called on server initialisation and server finalization to define what to do with the world on these events. There is no default behaviour and you need to extend this class to redefine the behaviour.
Also it provides methods for adding and getting new RPZones:
* addRPZone
* getRPZone, which can be used with either RPZone.ID or RPObject.ID
Finally it also contains methods for managing RPObjects as:
* addRPObject, that need that our RPObject contains a valid RPZone.ID inside its RPObject.ID
* getRPObject
* modifyRPObject
* changeZone that moves one object from the old zone to the new zone and adds a proper valid id.
At last, RPWorld also contains a method called nextTurn that is called by RPManager to move from one turn to the next turn. It resets the delta<sup>2</sup> data.
==RPZone==
▲Objects must be stored somewhere, and we use Zones now to store them. A zone is just a container of Objects which has a name.
Each RPZone '''must''' have a unique name.
▲In order to improve the modifiability of the Marauroa platform we have made RPZone to be an interface so that if you want you can implement it as you
But in most cases, if you think the Delta<sup>2</sup> system is fine and matches your games style, you can use MarauroaRPZone that is our reference implementation of Delta<sup>2</sup> algorithm.
* a HashMap of RPObject.ID to RPObject
* a List of RPObject
* a Perception
The idea is to have already computed, in the Zone, the perception
In order to make perceptions work, you have to manually call the modify method so that you notify the zone about changes in a character or object.▼
▲Actually the perception is the same for all the players on the Zone.
[[Category:Marauroa]]
▲In order to make perceptions work, you have to manually call modify method so that you notify the zone about changes in a character.
{{#breadcrumbs: [[Marauroa]] | [[Navigation for Marauroa Developers|Internals]] | [[RolePlayingDesign|Role Playing Design]] }}
| |||