Introduction
I am writing a 2D soccer game which is kind of multiplayer. It is special in the way that players are driven by third party software. In short: Someone implements the given interface for controlling a soccer player, plugs his player implementation into the game engine together with the implementation of someone else’s player implementation and both implementations will play a soccer match against each other. This is similar (but simpler) to RoboCup’s Simulations Leage (http://www.robocup.org/robocup-soccer/simulation/, http://www.youtube.com/watch?v=BVWkndHk3AE) or MIT’s Battlecode (http://www.battlecode.org/) competition. The game is written in scala with use the akka (akka.io) actors.
I will copy parts of this introduction to other questions refering to this game as necessary.
Architecture overview
- There are model classes like Ball, Body (of the players), SoccerField, Goal etc.
- There is an interface which must be implemented by each player implementation.
- There is a central class MatchController which controlls the game process like state and cycles.
- Between the player implementations and the MatchController there are intermediate actors handling the communication between the players and the MatchController by message passing. The players can only see a limited interface implemted by these actors. The communication is transparent to the players. The players don’t know anything about the MatchController. They event don’t know that it exists. The only thing that the players know about is the limited interface provided by the intermediate actors.
- The MatchController is partially responsible for cheat prevention as it must validate incoming messages. For example it must handle the case that a player tries to exeed maximum movement speed.
The isolation problem
Currently the player implementations are executed in the same process together with the MatchController. I assume that there are possibilities for player implementations to cheat or manipulate the game for example through use of reflection / meta programming.
In the middle or long term, I would like to isolate the player implementations from each other and the MatchController. Ideally even players of the same team and with the same implementation would be isolated from each other.
Which options do I have to get such isolation?
What are the advantages and disadvantages of these options?
Here are the ideas that came to my mind:
- Each player in a separate operating system process. This looks most promising, because it is a well known and established way of isolation. Maybe this will consume much memory and swap space, at least this happens when I use Chromium on my Linux system (compared to Firefox), but this is a little bit speculative from my perspective. Memory consumption may be limited by JVM settings.
- There is something like a Java Isolation API. Don’t know much about it, but may reduce memory consumption.
- Sandbox / Security Manager / Security Policy. Don’t know if it is possible to create proper isolation of different parts of a Java program. Might be combined with the OS process aproach to prevent the player processes to perform disallowed actions. If I think of an unlikely but really evil player implementation it might e.g. discover the oponent’s player processes and stop them. There where some vulnerabilities permitting a Java program easily bypass the Security Manager and break out of the sandbox, last year. I don’t know if they are all fixed now.
- I think there a couple of other aproaches trying to create isolation on the Java platform partially by modifiing the JVM’s architecture, but I don’t know if there are any of them at a usable state of progress in implementation and standardization.
- JCSP. Don’t know much about it, yet. http://www.cs.kent.ac.uk/projects/ofa/jcsp/, http://www.java-gaming.org/topics/jcsp-lw-isolated-processes-threads-in-java/2711/view.html
Do you have any more options or some hints or comments on isolation?
Thanks in advance.