Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
You can create a controller for the GVG-AI competition just by creating a Java class that inherits from core.player.AbstractPlayer.java. This class must be named Agent.java and its package must be the same as the username you used to register to this website (this is in order to allow the server to run your controller when you submit). This class must implement two public methods:
- public Agent(StateObservation so, ElapsedCpuTimer elapsedTimer): the constructor of the class.
- public Types.ACTIONS act(StateObservation stateObs, ElapsedCpuTimer elapsedTimer): the function called every game cycle to retrieve an action from the controller.
As you can see, both methods receive two parameters:
- StateObservation so: The StateObservation is the window the agent has to the world. See Forward Model for detailed information.
- ElapsedCpuTimer elapsedTimer: The ElapsedCpuTimer is an class that allows querying for the remaining CPU time the agent has to return an action. You can query for the number of milliseconds passed since the method was called (elapsedMillis()) or the remaining time until the timer runs out (remainingTimeMillis()). Exiting these functions after the timer has finished (when remainingTimeMillis() ≤ 0) would make this controller to be disqualified in the game being played.
Finally, the method act returns an action of the enum type Types.ACTIONS. The typical values for this type are: ACTION_NIL, ACTION_UP, ACTION_LEFT, ACTION_DOWN, ACTION_RIGHT and ACTION_USE. The first element indicates no action, the next four indicate movement actions, and the last one is used to execute an action (depending on the game, this could mean different things).
Be aware that not all games will allow the agent to execute all actions of the type Types.ACTIONS. It is the agent's responsibility to return an action that is allowed for the game being played at the moment. The list of available actions for the given game can be obtained calling the StateObservation method getAvailableActions(), that returns an object of type ArrayList<Types.ACTIONS>.
The following pages show different sample controllers that can help you get started with your controller: