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.
The balancing problem
I would would like to see, that a player wins a math, because of a superior algorithm and superior implementation and not because of other criterea like availible computation power. So resources, especially CPU, time must be balanced and ideally equally distributed over the players, resulting in a fair competition.
What general concepts, approaches and availible implementations / APIs exist to solve this problem?
Here are some approaches I can think of:
- The battlecode implemtation does execute a limited amount of bytecode (I think per cycle). Cycles are completely transparent to the player implementation. I think they use ASM (http://asm.ow2.org/), but I am afraid they made some customizations (don’t know exactly).
- Maybe I can use a custom scheduler, dispatcher or something similar (maybe rewriting some class of akka), to perform “round-robin” or something similar.
- There is a discussion on this topic here: http://www.techtalkz.com/java/130899-byte-code-execution-count.html with a proposal to use java.lang.management to measure CPU time. Don’t know more about this, yet.
Do you have experience with this problem, some hints or other approaches to share?
Thanks in advance.