Stuart Mathews
  • Home

    Latest

    • Functional XML (Game Development) 19-02-2023
    • Midnight in Paris (Blog) 04-01-2023
    • Christmas Run (Running) 26-12-2022
    • So far, it works (Game Development) 25-12-2022
    • Traveling Europe (Blog) 01-11-2022
    • Applying and Evaluating Pattern-Oriented Designs In Improving Code Quality In Complex Software (Code) 01-10-2022
    • Knoydart Peninsula, Scotland (Running) 01-10-2022
    • CppGameLib (Game Development) 12-09-2022
    • Thoughts on Multiplayer Game Co-operation and Distributed Computing (Game Development) 04-07-2022
    • The fading importance of ego and the utility of the checklist (Blog) 18-04-2022

    Most Read This Year

    • Thoughts on Multiplayer Game Co-operation and Distributed Computing (Game Development)
    • The fading importance of ego and the utility of the checklist (Blog)
    • Differential Calculus (Blog)
    • Traveling Europe (Blog)
    • Knoydart Peninsula, Scotland (Running)
    • CppGameLib (Game Development)
    • Applying and Evaluating Pattern-Oriented Designs In Improving Code Quality In Complex Software (Code)
    • So far, it works (Game Development)
    • Christmas Run (Running)
    • Midnight in Paris (Blog)

    Recently Featured

    • Functional XML (Game Development)
    • So far, it works (Game Development)
    • Thoughts on Multiplayer Game Co-operation and Distributed Computing (Game Development)
    • A software engineering process for delivering software (Code)
    • Encrypting strings at rest (Code)
    • ISO27001, Machine-Learning and Game dev (Blog)
    • Implementing a Vignette (Code)
    • Fixing the thunder in my feet (Running)
    • Sufficiently Complex (Blog)
    • Try Monad, Progress and Lockdown Rules (Blog)
    • Downloads
  • Blog

    Recent in Blog

    • Midnight in Paris 04-01-2023
    • Traveling Europe 01-11-2022
    • The fading importance of ego and the utility of the checklist 18-04-2022
    • Differential Calculus 14-04-2022
    • Fading importance and the utility of lists 29-12-2021
    • Abstractions and Patterns 11-10-2021
    • Mind Maps 02-10-2021
    • ISO27001, Machine-Learning and Game dev 23-04-2021
    • Sufficiently Complex 02-12-2020
    • Deadlocks and databases 19-10-2020

    Most Read In Blog This Year

    • The fading importance of ego and the utility of the checklist (Blog)
    • Differential Calculus (Blog)
    • Traveling Europe (Blog)
    • Midnight in Paris (Blog)

    Featured In Blog

    • ISO27001, Machine-Learning and Game dev (Blog)
    • Sufficiently Complex (Blog)
    • Try Monad, Progress and Lockdown Rules (Blog)
    • Rails, Euclid and Generating Mazes (Blog)
    • Set Theory, Ruby and Upgrades (Blog)
    • Time shifting, CS algorithms and Game Architecture (Blog)
    • The Fourier transform, math, malware and decoupling (Blog)
    • Encryption and network protocols (Blog)
    • Mazer Game Design and Network Security (Blog)
    • Changing object states and 3D transformations (Blog)
  • Code

    Recent in Code

    • Applying and Evaluating Pattern-Oriented Designs In Improving Code Quality In Complex Software 01-10-2022
    • Polynomial Calculator 16-03-2022
    • A software engineering process for delivering software 27-02-2022
    • Counting and Permutations 08-02-2022
    • Encrypting strings at rest 10-12-2021
    • Implementing a Vignette 26-01-2021
    • Functional programming paradigms and techniques 19-07-2020
    • Ruby RSpec let and let! diffirences 08-07-2020
    • Convolution, Running and Finite State Machines 08-03-2020
    • LanguageExt tutorial, games and timing 08-08-2019

    Most Read In Code This Year

    • Thoughts on Multiplayer Game Co-operation and Distributed Computing (Game Development)
    • CppGameLib (Game Development)
    • Applying and Evaluating Pattern-Oriented Designs In Improving Code Quality In Complex Software (Code)
    • So far, it works (Game Development)
    • Functional XML (Game Development)

    Featured In Code

    • Functional XML (Game Development)
    • So far, it works (Game Development)
    • Thoughts on Multiplayer Game Co-operation and Distributed Computing (Game Development)
    • A software engineering process for delivering software (Code)
    • Encrypting strings at rest (Code)
    • Implementing a Vignette (Code)
    • Protocols, Packets and Prototypes (Game Development)
    • Animated aliens and alternatives algorithms (Game Development)
    • Retro sounds, Event Manager and some running (Game Development)
    • Basic key frame animations, implicit casts and some other aspect (Game Development)
  • Running

    Recent in Running

    • Christmas Run 26-12-2022
    • Knoydart Peninsula, Scotland 01-10-2022
    • Winter running 09-12-2021
    • Itchy legs and tracksuit bottoms 03-09-2021
    • Heart rate inconsistency 26-04-2021
    • Chequered Leaves and the Yellow Runner 01-01-2021
    • Fixing the thunder in my feet 04-12-2020
    • Faster than usual 17-06-2020
    • The uncomfortable steady-state 03-06-2020
    • Hot weather running 31-05-2020

    Most Read In Running This Year

    • Knoydart Peninsula, Scotland (Running)
    • Christmas Run (Running)

    Featured in Running

    • Smashrun
    • Strava profile
  • Gaming

    Recent in Gaming

    • Functional XML 19-02-2023
    • So far, it works 25-12-2022
    • CppGameLib 12-09-2022
    • Thoughts on Multiplayer Game Co-operation and Distributed Computing 04-07-2022
    • Applying and Evaluating Functional Programming Paradigms and Techniques in Developing Games 19-02-2022
    • Christmas Period Tinkering 29-12-2021
    • Mazer Game Architecture Report 22-11-2020
    • Ruby Mazer 26-05-2020
    • Protocols, Packets and Prototypes 29-11-2019
    • Pleasure And the Execution of Thoughfulness 29-09-2019

    Most Read In Gaming This Year

    • Thoughts on Multiplayer Game Co-operation and Distributed Computing (Game Development)
    • CppGameLib (Game Development)
    • So far, it works (Game Development)
    • Functional XML (Game Development)

    Featured in Gaming

    • Game loop
    • Featured
  • Portfolio

    Featured in Portfolio

    • App-V (Citrix)
    • Citrix Fast Connect SDK
    • AppDNA
    • Cloud Copy and Paste
    • Software Audit Pro
    • Investment Manager
    • Meal tracker
    • Cross platform broker
  • About

Thoughts on Multiplayer Game Co-operation and Distributed Computing

Details
Stuart Mathews
Code
Game Development
04 July 2022
Created: 04 July 2022
Last Updated: 04 January 2023
Hits: 840

Since being on holiday I've been making some progress on my game prototype. I've implemented the foundations for a multi-player experience. This has been quite interesting. Firstly, I tried to implement a simple client-server architecture using TCP sockets by implementing a GameServer (if you want to be the game server) or GameClients (for each player that doesn't).

The first implementation was slow due to the constant verification that TCP has to do to ensure that traffic arrives, in order and without packet loss. I tried to implement it instead without such guarantees using UDP and indeed this improved the performance drastically.

The basic design is a system where each client registers with the game server, akin to joining a lobby in a multi-player game and as each new player arrives in the lobby details about the player is captured, such as asking the client to tell the GameServer who he is (NickName). The game server stores reference to where the client is - if we're using TCP then this will be the socket that the client used to communicate with the server, if using UDP (which is faster, so preferred) then we store the client's source port on the game server (I use connected UDP). This way the game server can talk back to the client, something like this.

How it all works, is that if a client raises an event such as moving the player, this event is serialized and forwarded to the game server, who then in return distributes that same message to all the other game clients (with the exception of the original sender). In doing so the original sender's nickname is labelled as the target of the event so that when the message reaches the clients, they know who in the system that event is for, i.e it's for the player that moved, so each client can move that particular player in that particular way so that all players see the same player move on their screens. Equally, if the game server (who is also a player) moves, this event is serialized and sent to all players, again labelling the event as being from the game server player's nickname. Each system has an event queue that is added to by reading these events off the network when they are sent by the Game server - here is a simple design.

In general, the mechanism works well in terms of the coordination of notifying other players what one specific player did. I've yet to integrate it fully to actually see the player that moved, move the same way on all the other player's screens - but the messaging and the networking is all there - backed by UDP or TCP. Getting the architecture setup in this way is a milestone. Like most things that are well implemented, it takes time to move from each stage of the design because one needs to fully evaluate what the next stage needs/should be and, more importantly, that it will be useful and not a wasted effort of coding. In this way, designing and thinking is an important next step and when I reach a milestone like this,  I like to take a break and think about how to move from this milestone to the next one. So that's where I am right now.

One thing that has become clear is that in order to fully create a multi-player game, where all participants move and respond on each players screen, requires level initialization so that we can dynamically initialize a level with as many players as having joined, and then tell all of them to use the same level initialization and level creation parameters when starting the level on their screens in the same way, i.e complete with all the positions of all the other players. So there needs to be some dynamic collaboration to say, 'hey, these are all the players and they are here and here in the level, go and create the level that way when the game starts'. This needs to be done on all clients so all clients look the same way so that messages targeted for players actually reach players because they have been added/created to the same level that all other players are playing. This is the next milestone. 

But while I know what needs to be done, I've been travelling and working and well it's a great time to do other things while you're at a milestone and you don't need to finish anything yet as you've not started the next thing. So, I've been thinking about the general idea behind distributed networking and participant collaboration (because that is what a multiplayer system is really), and how it is generally an information collaboration system used for many types of problems. You could use it for collaborating on individual results that a client has come up with, in like a distributed computing scenario. I think this is where computer games technology is so interesting and useful for so many other things, particularly via network programming - as it allows you to design systems that can be used in other distributed scenarios like to create say a map-reduce environment or some other clustering environment where resources, results and information are shared across multiple participants just like in a multi-player game. The interesting thing is that it's not just about communicating across the network, its about communicating across the network to inform other people what you've done or what someone else has done, and in so many applications knowing what exactly someone has done in your network is useful because its the basis for collaboration or at least, of information sharing.

In many ways, I already knew this from my work creating the distributed broker but it never actually told everyone else what one person is doing, it never radiated the effects of one person to all others concerned, and it also never used UDP, so that is cool.

What are the applications or concerns for such a system?  

  1. Too much information perhaps, not everyone wants to know about all other's information, but in games we definitely do, we want to know exactly what the other players are doing so that we can emulate that behaviour on all our screens. In fact, this would be useful in distributing real-time messages to multiply display boards, say at an airport or train terminal. 
  2. With so much data flying around, security and integrity of that data are important, particularly if you need to be 100% sure that the information you've received is exactly as it was intended (it hasn't changed, ie its integrity is in check) and that it's absolutely from the person who sent it. So perhaps ensuring that the data transmitted is secure is important, generally. For a coordinated and distributed algorithm implemented a distributed game agents absolutely. For a network game, maybe a lack of security could compromise the integrity of the game (someone is changing the network data and messing things up)
  3. Latency would be an issue for games, if it takes ages to act on a piece of information, then the real-time nature of a game is compromised. If the system is not real-time, then this wouldn't matter - it gets it when it gets it. Could implement the TCP mechanism to improve the reliability in these types of systems. Possibly compression, encryption and hashing be used to improve both the security and latency by reducing the size of transmitted data, but how would it affect the performance?
  4. A system that reports all the activity of others could be useful for auditing purposes - ie replicating what has happened to multiple places that it guaranteed that what has happened can be verified. 
  5. It could also be a useful way to distribute the same information to agents that use it differently like each one applies or uses the data differently, say uses a distinct algorithm and this way multiple 'tests' could be run in parallel, i.e each receiving agent can run use the received data at the same time and report back its results. 

I can't think of any more uses but distributed computing is basically what we're talking about and that is a huge field. I'd like to probably think a little more about the security of distributed computing, particularly in networked games or how implementing it could affect the gaming experience. That's perhaps for another day.

 

 

holiday Programming Game development Networking and security
Write comment (0 Comments)

More Articles ...

  1. A software engineering process for delivering software
  2. Encrypting strings at rest
  3. ISO27001, Machine-Learning and Game dev
  4. Implementing a Vignette
  5. Fixing the thunder in my feet
  6. Sufficiently Complex
  7. Try Monad, Progress and Lockdown Rules
  8. Rails, Euclid and Generating Mazes
  9. Set Theory, Ruby and Upgrades
  10. Time shifting, CS algorithms and Game Architecture
Page 3 of 65
  • Start
  • Prev
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • Next
  • End

Topics

Running (36) Programming (34) Game development (28) Random (22) Impressions (19) holiday (19) Math (18) C++ (16) Wierd (12) Gym (11) Traveling (10) Functional programming (10) Software Engineering (10) TCP/IP (9) Networking and security (7) Investing (6) Linux kernel (6) DirectX (6) XML (5) Ruby (5)

Twitter

Tweets by @stumathews

Latest

  • Functional XML (Game Development) 19-02-2023
  • Midnight in Paris (Blog) 04-01-2023
  • Christmas Run (Running) 26-12-2022
  • So far, it works (Game Development) 25-12-2022
  • Traveling Europe (Blog) 01-11-2022
  • Applying and Evaluating Pattern-Oriented Designs In Improving Code Quality In Complex Software (Code) 01-10-2022
  • Knoydart Peninsula, Scotland (Running) 01-10-2022
  • CppGameLib (Game Development) 12-09-2022
  • Thoughts on Multiplayer Game Co-operation and Distributed Computing (Game Development) 04-07-2022
  • The fading importance of ego and the utility of the checklist (Blog) 18-04-2022

Recent

  • Functional XML
  • Midnight in Paris
  • Christmas Run
  • So far, it works
  • Current Reading

Share This

Follow Me

Login

  • Login
  • Webmail
  • Admin
  • Downloads
Bootstrap is a front-end framework of Twitter, Inc. Code licensed under MIT License. Font Awesome font licensed under SIL OFL 1.1.