James Keats

Game Programmer

Fall 2016: Networking for Online Games - Networked Boids

Side Project / Professor Challenge

James Keats // Programmer

This project was not a game, but more of a tech demo. It emerged from a challenge prompted by my professor for Artificial Intelligence for Games, Dean Lawson. In our Game AI class, one of the first things we discussed was steering and flocking using the classic rules for cohesion, alignment, and seperation. My professor noted that most Game Programmers took Networking for Online Games at the same time as AI, and he loved to see people combine the two classes in interesting ways. Something in particular that he always wanted to see was a huge flock of networked boids circling around the entire room. One of my friends, Charlie McGarey, and I raced to see who could network our boids first. This was the result.

This project is built entirely in C++ from the ground up by me. The core graphics framework is Allegro, but this was abstracted out into a generic graphics system. The networking was done using RakNet.

Unfortunately, it's a logistical nightmare to record the project working across an entire computer lab. Instead, here's a video of the Boids running across 4 local instances:

The project was made using a client-server architecture. The following flow was used to improve simplicity:

  • When a client connects to the server, it says where it is in relation to the rest (using a user-input number system, where higher numbers are further to the right).
  • When a Boid leaves a client's view, it notifies the server of that Boid's position, velocity, rotation, and angular velocity.
  • The server determines which screen that Boid should move to, and sends an update to that client with the Boid's data.
Note that not every single Boid gets its own networked message. Instead, changes are accumulated over the span of a few frames, leading to less network spam and still acceptable AI results. The AI itself is not networked, and the Boids simply do flocking with whatever exists on the local instance.

In retrospect, this project would have been significantly easier with a peer-to-peer architecture instead of client-server, but this choice made sense at the time with what we had learned in class.

The Networked Boids project was a fun little side thing, and looks awesome when the Boids travel across large distances. Reach out to me at contact@jameskeats.com if you want an executable of the project!

Desktop Site