Passing arguments to the configuration class

To avoid needing multiple copies of the same configuration class, it is sometimes necessary to pass arguments to the configuration class. This is currently a little bit unintuitive, but nonetheless very simple to implement.

Here's a list of what you need to do:

  • Create a small ___Arguments class that is unique to your experiment and contains the fields you need to pass (make them public for simplicity).
    • This class has to implement Serializable.
    • The class must be contained in a namespace that is import'ed in the file edu.harvard.eecs.airg.coloredtrails.server.CtrlCommands. Otherwise, the application will crash when trying to deserialize the class.
      I recommend using edu.harvard.eecs.airg.coloredtrails.shared.types
  • In your controller, pass an instance of your arguments class into the Game class's constructor, through the data parameter (currently the last parameter).
  • In your configuration class's constructor (or other initialization method), retrieve the arguments by calling gs.getDataFromController() and casting the result to your ___Arguments class, e.g.
    MyConfigArguments args = (MyConfigArguments)gs.getDataFromController();
    Note: gs is a protected member of the GameConfigDetailsRunnable class, which your Configuration class extends.