edu.ou.mlfw
Class World<STATE,ACTION>

java.lang.Object
  extended by edu.ou.mlfw.World<STATE,ACTION>

public class World<STATE,ACTION>
extends java.lang.Object

World is where a Simulator, that simulator's Controllables, and a set of Clients are all brought together, and an instance of the simulator is run. The initialization process is largely driven by a World configuration file or object that points to a Simulator configuration and the various Client configurations, and specifies how clients are paired with Controllables. This class also provides control for the gui if display is desired by the user.


Nested Class Summary
static class World.Arguments
          A throwaway class that encapsulates the command line arguments for World.
 
Field Summary
static java.lang.String DEFAULT_CONFIG
           
 
Constructor Summary
World(WorldConfig worldconfig)
          Initialize the simulator, initialize each client, and bind each controllable to its client.
 
Method Summary
static void exit(java.lang.String exitMessage)
          Exits the program with usage instructions.
 java.util.List<Record> getRecords()
          Return a list of Records, corresponding to the statistics stored for each controllable over the course of a game.
static void main(java.lang.String[] args)
          Load up the specified or default configs and start an instance of the simulator run.
static World.Arguments parseArgs(java.lang.String[] args)
          Handle the command-line arguments passed to an invocation of World.
 void run()
          The basic run loop.
 void runGUI()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CONFIG

public static final java.lang.String DEFAULT_CONFIG
See Also:
Constant Field Values
Constructor Detail

World

public World(WorldConfig worldconfig)
      throws java.lang.InstantiationException,
             java.lang.IllegalAccessException,
             NameCollisionException,
             OverboundControllableException,
             UnboundClientException,
             UnboundControllableException,
             java.lang.ClassNotFoundException,
             java.io.FileNotFoundException,
             java.io.IOException
Initialize the simulator, initialize each client, and bind each controllable to its client. Throws an exception if either a controllable is initialized without a matching client, or a client is initialized without a matching controllable. If a controllable/client pair is given but neither the controllable or client are initialized, the pair entry will simply be ignored. This also initializes the gui if the graphical option is specified.

Throws:
java.lang.IllegalAccessException
java.lang.InstantiationException
NameCollisionException
UnboundClientException
UnboundControllableException
OverboundControllableException
java.lang.ClassNotFoundException
java.io.FileNotFoundException
java.io.IOException
Method Detail

run

public void run()
The basic run loop. While the simulator reports that it is running, we drive the simulation with two phases per loop. In the first phase, we iterate over each controllable, find the client associated with that controllable, pass the simulator state to the client, and pull out the controllable's legal actions and pass them to the client. Once we have the state and legal actions ready for the client, we pass these to the client's startAction() method. From this call, we receive an action, which we use to set the Controllable's action. Once all the controllables have an action, we advance the simulator. TODO: Should time be passed in here? Would this be the best way to handle synchronizing simulator time with gui framerate? After the simulator has advanced, we pull out the new state, and pass that state to each client's endAction() method. Finally, if the gui is enabled, we draw the game state.


runGUI

public void runGUI()

getRecords

public java.util.List<Record> getRecords()
Return a list of Records, corresponding to the statistics stored for each controllable over the course of a game. This ensures that each record has the appropriate display name associated with it.

Returns:
A list of Record objects.

main

public static void main(java.lang.String[] args)
Load up the specified or default configs and start an instance of the simulator run.

Parameters:
args -

parseArgs

public static World.Arguments parseArgs(java.lang.String[] args)
Handle the command-line arguments passed to an invocation of World. Generates an Arguments object, which is a simple encapsulation of the relevant command-line options and values into an object.

Parameters:
args - The arguments string.
Returns:
An instance of Arguments encapsulating the relevant args.

exit

public static void exit(java.lang.String exitMessage)
Exits the program with usage instructions.