-
Notifications
You must be signed in to change notification settings - Fork 48
Creating Controllers
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:
-
GVG Framework
- Tracks Description
- Code Structure
- Creating Controllers
- Creating Multi Player Controllers
- Creating Level Generators
- Running & Testing Level Generators
- Creating Rule Generators
- Running & Testing Rule Generators
-
Forward Model and State Observation
- Advancing and copying the state
- Advancing and copying the state (2 Player)
- Querying the state of the game
- Querying the state of the game (2 Player)
- Information about the state of the Avatar
- Information about the state of the Avatar (2 Player)
- Information about events happened in the game
- Information about other sprites in the game
- Game Description Class
- Constraints
- Game Analyzer Class
- Level Analyzer Class
- Sprite Level Description Class
- Sprite, Termination, and Interaction Data Class
- Level Mapping Class
- Competition Specifications
- VGDL Language