<-References       Go to ToC      Guidelines and Example->

 

Functions Reference Model Input/Output Data
Functions of AI Modules I/O Data of AI Modules Reference Software

1       Functions

The model considered by SPG-MDL exploits Neural Networks to make accurate Game States predictions. Whenever a client packet is lost, the server evaluates the new Game State thanks to the SPG-MDL prediction: if it is accurate, the Latency of a player is invisible to the unaffected clients without decreasing the game responsiveness or fairness. The Prediction can also be used to detect cheating attempts by comparing the prediction with the server Game State. This use, however, is not considered by SPG-MDL V1.0.

SPG-MDL focuses on keeping the game synchronised between server and clients. Whenever the server needs to evaluate a new Game State, the server requests the SPG-MDL module (Figure 4) to compute the next state through AI Modules before updating the game. If there is any missing data or if the evaluated Game State is too different from the SPG-MDL prediction, the server uses the latter to update the Game State.

In this way, even if a client is experiencing Latency, it is perceived by the other clients as having a continuous playing behaviour. The advantage of this method is that, if predictions are accurate, the effect of the synchronisation process on the lagging client is not noticeable to the player when the network resumes normal operations. Additionally, SPG-MDL helps with reducing the server-client delay. A client with high latency will still receive the results of its actions with a delay, but the server will send the new Game State before receiving the action from the client, effectively halving the waiting time. Therefore, all clients can achieve an optimal user experience. Since MPAI-SPG-MDL is installed only on the server, it is possible to implement additional techniques at Client side to mitigate this problem, for example Client Prediction.

2       Reference Model

As SPG-MDL works in an authoritative server context, the server evaluates a new Game State at every time step using all CDs received from remote players (Figure 3).

Figure 3 – An Authoritative server

Once computed, the new GS is distributed to each client instance. Within the SPG-MDL framework, the Game State is composed of a series of Game Messages (GM), which are output from three principal engines:

  1. Behaviour Engine, orchestrating actions from players and non-player entities.
  2. Rules Engine, ensuring adherence to game mechanics.
  3. Physics Engine, responsible for physical interactions within the game environment.

SPG-MDL is a “twin” Game Server that is called into action when some CDs are not received (Figure 4). The following steps explain the procedure:

  1. The server feeds the current Game State (GSt) to the SPG-MDL’s Game State Demultiplexer.
  2. The Demultiplexer deconstructs the Game State into discrete Game Messages* (GMt) where the added ‘*’ symbol differentiates these Game Messages from those of the server.
  3. Each Game Message* is processed by its respective Engine AI, a trained Neural Network Model that produces a predicted Game Message* (pGMt+1).
  4. The Predicted Game State Multiplexer assembles all predictions and forms the predicted Game State (pGSt+1).
  5. The predicted Game State is communicated back to the server for the next iteration of Game State evaluation.
  6. The server uses the predicted state to compensate for the data shortfall from one or more clients.

Figure 4 – Mitigation of Data Latency effects AIW (SPG-MDL)

Note that:

  1. The formats of both the computed and predicted GSs are the same.
  2. The server independently computes its updated Game State (GSt+1), which is solely derived from available CDs.
  3. The server utilises pGSt+1 when any Client Data is missing.
  4. The online game server architecture described in this section is a reference model. The three engines are not a requirement for any kind of game for which the MPAI-SPG methodology is applied. For example, some games may not use a Physics Engine if physical-based behaviour is not required.

3       Input/Output Data

Table 2 provides the input and output data of SPG-MDL:

Table 2 – I/O Data of AI Modules of Mitigation of Data Latency effects (SPG-MDL)

Input Description
Game State The Game Server Game State at the preceding time instant.
Control Data Set of players’ Control Data at current time.
Output Description
Game State Predicted Game State at time current time.

4       Functions of AI Modules

Table 3 provides the functions of SPG-MDL.

Table 3 – Functions of AI Modules of Mitigation of Data Latency effects (SPG-MDL)

AIM Function
Game State Demultiplexer Demultiplexes the Game State into its components.
AI-Physics Engine Predicts the output of the twinned Physics Engine
AI-Rules Engine Predicts the output of the twinned Rules Engine
AI-Behaviour Engine Predicts the output of the twinned Behaviour Engine
Predicted Game State Multiplexer Assembles the components of the predicted Game State

5       I/O Data of AI Modules

Table 4 lists the AI Modules and the corresponding input and output data.

Table 4 – I/O Data of AI Modules of Mitigation of Data Latency effects (SPG-MDL)

AIM Receives Produces
Game State Demultiplexer Game State
Controller Data
Game Message for AI-Physics Engine
Game Message for AI-Rules Engine
Game Message for AI-Behaviour Engine
AI-Physics Engine Game Message for AI-Physics Engine Game Message from AI-Physics Engine
AI-Rules Engine Game Message for AI-Rules Engine Game Message from AI-Rules Engine
AI-Behaviour Engine Game Message for AI-Behaviour Engine Game Message from AI-Behaviour Engine
Predicted Game State Multiplexer Game Message from AI-Physics Engine
Game Message from AI-Rules Engine
Game Message from AI-Behaviour Engine
Predicted Game State

6       Reference Software

6.1      Disclaimers

  1. This SPG-MDL Reference Software Implementation is released with the BSD-3-Clause licence.
  2. The purpose of this Reference Software is to provide a working Implementation of SPG-MDL, not to provide a ready-to-use product.
  3. MPAI disclaims the suitability of the Software for any other purposes and does not guarantee that it is secure.
  4. Use of this Reference Software may require acceptance of licences from the respective repositories. Users shall verify that they have the right to use any third-party software required by this Reference Software.

6.2      Guide to the SPG-MDL code

The game was developed using the Unity game engine, and the networking features implemented through the opensource game networking library Mirror.

The following components are provided:

  • The car racing game
  • 4 different categories of Agent Players trained using Unity’s ML-Agents library
  • The dataset used for training, generated simulating game sessions played by the Agent Players
  • Jupyter notebooks for training experiments and results
  • The trained models used by the AI-Behaviour Engine

Available at https://experts.mpai.community/software/mpai-spg/car-racing-game/

Registration is required to access the repository. Details on how to use all the material is provided in the repository’s README page.

 

<-References       Go to ToC      Guidelines and Example->