-
Notifications
You must be signed in to change notification settings - Fork 48
Sample Random Controller (2 Player)
Raluca D. Gaina edited this page Feb 12, 2018
·
1 revision
This is a very simple, completely functional controller for the Two Player Track of GVG-AI. It does not take into account the fact that there is a second player in the game, it just returns a random action to be executed in the next game cycle.
Note that this class extends AbstractMultiPlayer (and not AbstractPlayer, the single player version) and that the player ID is caught in the constructor and used to access the list of actions available for this particular player.
package random; //The package name is the same as the username in the web.
public class Agent extends AbstractMultiPlayer {
int id; //this player's ID
/**
* initialize all variables for the agent
* @param stateObs Observation of the current state.
* @param elapsedTimer Timer when the action returned is due.
* @param playerID ID of this agent.
*/
public Agent(StateObservationMulti stateObs, ElapsedCpuTimer elapsedTimer, int playerID){
id = playerID;
}
/**
* return ACTION_NIL on every call to simulate doNothing player
* @param stateObs Observation of the current state.
* @param elapsedTimer Timer when the action returned is due.
* @return ACTION_NIL all the time
*/
@Override
public ACTIONS act(StateObservationMulti stateObs, ElapsedCpuTimer elapsedTimer) {
ArrayList<ACTIONS> a = stateObs.getAvailableActions(id);
return ACTIONS.values()[new Random().nextInt(a.size())];
}
}
-
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