Multiplayer Football Simulation
The multiplayer football simulation was for the Simulation and Concurrency module, which I did in the second semester at Hull. It was quite a huge project, compromising of physics, networking, threading, AI, and all the other random stuff that makes up a game. Towards the end I was working on 48hr days as I'd only end up getting to bed every second night. I'm not even in the industry yet and I already hate crunch time.
Like I said before, the brief was tear-inducingly huge for the amount of time we had to make it, added to the other projects on the go at the same time (peaked at something like 5 at once). Briefly (if you'll excuse the pun, aha-ha):
- Make a distributed 5-a-side football game. Users can either join as players or spectators
- Controls to be implemented via a joysticked controller (and also continuing the University's penchant for choosing random buttons against all laws of conformity)
- Pause and replay to be implemented. If you're a player, then this pauses / replays for everyone on the server. If you're a spectator, then it's just for yourself
- Users joining as players control one player, with simple AI controlling all the rest. If a player's connection drops, then the AI has to take over immediately
- As this was partially an exercise on threading, then the threads worked as such: on the client - the main thread and one for networking; on the server - the main thread, one for networking, one for physics, and one for each player
- Fault tolerance to be implemented. If a player drops, then the game shouldn't stall and the AI should take over
- For the physics, a basic simulation model needed to be implemented. You move the players by applying forces to them. Realistic collision detection / response, air friction, ground friction, elastic collisions etc. Extra marks for implementing a rigid body simulation with associated spin etc.
- Goal nets to be modeled, with realistic collisions and reaction with the ball
- All the physics, AI, etc. to be done on the server and sent over to be rendered on the client
- System has to handle 10 player connections, and numerous observer connections
- Only simple graphics were asked for, i.e. modeling the players as spheres etc. Shadows were asked for to make it easier to judge how high the player is off the ground
The Finished Version
The finished version (though I'm still probably going to add more stuff to it) includes pretty much everything except the rigid body physics and goal net spring and dashpot modeling. It does however look very pretty and is also pretty fast, even with all those connections.
Controlling the players by applying force tends to make it quite difficult to actually hit the ball unless you start from a standing start and the ball doesn't move in the mean time. Still, it's quite fun to play, especially with a lot of people.
I implemented quite simple AI for this. Basically each player has a zone of control (see the server picture in the Images section to see what I mean). If the ball enters this zone, then the player gets a vector from the ball to where the opposing goal is. It then extends this out to a point on the ball and aims to hit that. Simple, effective, and sometime frustrating when you're about to hit your carefully lined up shot and an AI player plows into the ball and sends it to the opposite end of the court. There is one big flaw in it, which if you think it out becomes immediately obvious, but I'm not too bothered about it so I left it in.
I actually really liked working on this project, so I plan to revisit it when I've a bit more free time and put in some goal nets. Ah, the challenge of developing a net that doesn't go mental when touched...
Anyway, I've stuck up some images of the game in action, though you can also check out some movies of it as well. As for downloads, you can download the source code (1.98Mb), the release version of the client (1.89Mb), the release version of the server (29Kb), and the project report (150Kb). If you want to play it over a LAN, then just get the IP address of whomsoever's running the server, and plug it into the environment.txt file. Enjoy!