Tabnine Logo
GridGame
Code IndexAdd Tabnine to your IDE (free)

How to use
GridGame
in
burlap.domain.stochasticgames.gridgame

Best Java code snippets using burlap.domain.stochasticgames.gridgame.GridGame (Showing top 13 results out of 315)

origin: jmacglashan/burlap_examples

public static void QLCoCoTest(){
  GridGame gridGame = new GridGame();
  final OOSGDomain domain = gridGame.generateDomain();
  final State s = GridGame.getPrisonersDilemmaInitialState();
  JointRewardFunction rf = new GridGame.GGJointRewardFunction(domain, -1, 100, false);
  TerminalFunction tf = new GridGame.GGTerminalFunction(domain);
  SGAgentType at = GridGame.getStandardGridGameAgentType(domain);
origin: jmacglashan/burlap_examples

public static void saInterface(){
  GridGame gridGame = new GridGame();
  final OOSGDomain domain = gridGame.generateDomain();
  final State s = GridGame.getSimpleGameInitialState();
  JointRewardFunction rf = new GridGame.GGJointRewardFunction(domain, -1, 100, false);
  TerminalFunction tf = new GridGame.GGTerminalFunction(domain);
  SGAgentType at = GridGame.getStandardGridGameAgentType(domain);
origin: jmacglashan/burlap

public static void main(String[] args) {
  GridGame gg = new GridGame();
  OOSGDomain domain = gg.generateDomain();
  State s = GridGame.getTurkeyInitialState();
  JointRewardFunction jr = new GridGame.GGJointRewardFunction(domain);
  TerminalFunction tf = new GridGame.GGTerminalFunction(domain);
  World world = new World(domain, jr, tf, new ConstantStateGenerator(s));
  DPrint.toggleCode(world.getDebugId(),false);
  SGAgent ragent1 = new RandomSGAgent();
  SGAgent ragent2 = new RandomSGAgent();
  SGAgentType type = new SGAgentType("agent", domain.getActionTypes());
  world.join(ragent1);
  world.join(ragent2);
  GameEpisode ga = world.runGame(20);
  System.out.println(ga.maxTimeStep());
  String serialized = ga.serialize();
  System.out.println(serialized);
  GameEpisode read = GameEpisode.parse(serialized);
  System.out.println(read.maxTimeStep());
  System.out.println(read.state(0).toString());
}
origin: jmacglashan/burlap

/**
 * Returns the initial state for a classic coordination game, where the agent's personal goals are on opposite sides.
 * @return the coordination game initial state
 */
public static State getCorrdinationGameInitialState(){
  GenericOOState s = new GenericOOState(
      new GGAgent(0, 0, 0, "agent0"),
      new GGAgent(2, 0, 1, "agent1"),
      new GGGoal(0, 2, 2, "g0"),
      new GGGoal(2, 2, 1, "g1")
  );
  setBoundaryWalls(s, 3, 3);
  return s;
}

origin: jmacglashan/burlap

@Override
public OOSGDomain generateDomain() {
  
  OOSGDomain domain = new OOSGDomain();
  
  
  domain.addStateClass(CLASS_AGENT, GGAgent.class)
      .addStateClass(CLASS_GOAL, GGGoal.class)
      .addStateClass(CLASS_DIM_H_WALL, GGWall.GGHorizontalWall.class)
      .addStateClass(CLASS_DIM_V_WALL, GGWall.GGVerticalWall.class);
  
  domain.addActionType(new UniversalActionType(ACTION_NORTH))
      .addActionType(new UniversalActionType(ACTION_SOUTH))
      .addActionType(new UniversalActionType(ACTION_EAST))
      .addActionType(new UniversalActionType(ACTION_WEST))
      .addActionType(new UniversalActionType(ACTION_NOOP));
  
  
  OODomain.Helper.addPfsToDomain(domain, this.generatePFs());
  domain.setJointActionModel(new GridGameStandardMechanics(domain, this.semiWallProb));
  
  return domain;
}
origin: jmacglashan/burlap

/**
 * Returns the initial state for a simple game in which both players can win without interfering with one another.
 * @return the simple game initial state
 */
public static State getSimpleGameInitialState(){
  GenericOOState s = new GenericOOState(
      new GGAgent(0, 0, 0, "agent0"),
      new GGAgent(2, 0, 1, "agent1"),
      new GGGoal(0, 2, 1, "g0"),
      new GGGoal(2, 2, 2, "g1")
  );
  setBoundaryWalls(s, 3, 3);
  return s;
}

origin: jmacglashan/burlap_examples

public static void VICorrelatedTest(){
  GridGame gridGame = new GridGame();
  final OOSGDomain domain = gridGame.generateDomain();
  final HashableStateFactory hashingFactory = new SimpleHashableStateFactory();
  final State s = GridGame.getPrisonersDilemmaInitialState();
  JointRewardFunction rf = new GridGame.GGJointRewardFunction(domain, -1, 100, false);
  TerminalFunction tf = new GridGame.GGTerminalFunction(domain);
  SGAgentType at = GridGame.getStandardGridGameAgentType(domain);
  MAValueIteration vi = new MAValueIteration(domain, rf, tf, 0.99, hashingFactory, 0., new CorrelatedQ(CorrelatedEquilibriumSolver.CorrelatedEquilibriumObjective.UTILITARIAN), 0.00015, 50);
  World w = new World(domain, rf, tf, s);
  //for correlated Q, use a correlated equilibrium policy joint policy
  ECorrelatedQJointPolicy jp0 = new ECorrelatedQJointPolicy(CorrelatedEquilibriumSolver.CorrelatedEquilibriumObjective.UTILITARIAN, 0.);
  MultiAgentDPPlanningAgent a0 = new MultiAgentDPPlanningAgent(domain, vi, new PolicyFromJointPolicy(0, jp0, true), "agent0", at);
  MultiAgentDPPlanningAgent a1 = new MultiAgentDPPlanningAgent(domain, vi, new PolicyFromJointPolicy(1, jp0, true), "agent1", at);
  w.join(a0);
  w.join(a1);
  GameEpisode ga = null;
  List<GameEpisode> games = new ArrayList<GameEpisode>();
  for(int i = 0; i < 10; i++){
    ga = w.runGame();
    games.add(ga);
  }
  Visualizer v = GGVisualizer.getVisualizer(9, 9);
  new GameSequenceVisualizer(v, domain, games);
}
origin: jmacglashan/burlap

GridGame gg = new GridGame();
OOSGDomain d = gg.generateDomain();
State s = GridGame.getTurkeyInitialState();
origin: jmacglashan/burlap

/**
 * Returns the initial state for Friend Foe game.
 * @return the initial state for Friend Foe
 */
public static State getFriendFoeInitialState(){
  GenericOOState s = new GenericOOState(
      new GGAgent(3, 0 ,0, "agent0"),
      new GGAgent(6, 0, 1, "agent1"),
      new GGGoal(0, 0, 1, "g0"),
      new GGGoal(4, 0, 0, "g1")
  );
  setBoundaryWalls(s, 8, 1);
  return s;
}

origin: jmacglashan/burlap_examples

public static void VICoCoTest(){
  GridGame gridGame = new GridGame();
  final OOSGDomain domain = gridGame.generateDomain();
  final State s = GridGame.getPrisonersDilemmaInitialState();
  SGAgentType at = GridGame.getStandardGridGameAgentType(domain);
origin: jmacglashan/burlap

/**
 * Returns the initial state for the Incredible game (a game in which player 0 can give an incredible threat).
 * @return the initial state for the Incredible game.
 */
public static State getIncredibleInitialState(){
  GenericOOState s = new GenericOOState(
      new GGAgent(2, 0, 0, "agent0"),
      new GGAgent(3, 0, 1, "agent1"),
      new GGGoal(0, 0, 1, "g0"),
      new GGGoal(1, 0, 2, "g1")
  );
  setBoundaryWalls(s, 4, 1);
  
  return s;
  
}

origin: jmacglashan/burlap

/**
 * Returns the initial state for a classic prisoner's dilemma formulated in a Grid Game.
 * @return the grid game prisoner's dilemma initial state
 */
public static State getPrisonersDilemmaInitialState(){
  GenericOOState s = new GenericOOState(
      new GGAgent(3, 0, 0, "agent0"),
      new GGAgent(5, 0, 1, "agent1"),
      new GGGoal(0, 0, 1, "g0"),
      new GGGoal(4, 0, 0, "g1"),
      new GGGoal(8, 0, 2, "g2")
  );
  setBoundaryWalls(s, 9, 1);
  return s;
}

origin: jmacglashan/burlap

public static State getTurkeyInitialState(){
  GenericOOState s = new GenericOOState(
      new GGAgent(0, 0, 0, "agent0"),
      new GGAgent(2, 0, 1, "agent1"),
      new GGGoal(0, 3, 1, "g0"),
      new GGGoal(1, 2, 0, "g1"),
      new GGGoal(2, 3, 2, "g2"),
      new GGWall.GGHorizontalWall(0, 0, 1, 1, "w0"),
      new GGWall.GGHorizontalWall(2, 2, 1, 1, "w1")
  );
  setBoundaryWalls(s, 3, 4);
  
  return s;
  
}

burlap.domain.stochasticgames.gridgameGridGame

Javadoc

The GridGame domain is much like the GridWorld domain, except for arbitrarily many agents in a stochastic game. Each agent in the world has an OO-MDP object instance of OO-MDP class "agent" which is defined by an x position, a y position, and a player number. Agents can either move north, south, east, west, or do nothing, therefore the game is symmetric for all agents. To get a standard SGAgentTypeto use with this game, use the #getStandardGridGameAgentType(SGDomain) static method.

In this domain, there is also an OO-MDP object class for 1-dimensional walls (both for horizontal walls or vertical walls). Each wall can take on a different type; a solid wall that can never be passed (type 0), and a semi-wall, can be passed with some stochastic probability (type 1). Finally, there is also an OO-MDP class for goal locations, which also have different types. There is a type that can be indicated as a universal goal/reward location for all agents (type 0), and type that is only useful to each individual agent (type i is a personal goal for player i-1).

The JointModel set for the domain is burlap.domain.stochasticgames.gridgame.GridGameStandardMechanics, with a default semi-wall probability of passing through of 0.5, which is changeable with the

Most used methods

  • <init>
  • generateDomain
  • generatePFs
  • getPrisonersDilemmaInitialState
    Returns the initial state for a classic prisoner's dilemma formulated in a Grid Game.
  • getSimpleGameInitialState
    Returns the initial state for a simple game in which both players can win without interfering with o
  • getStandardGridGameAgentType
    Creates and returns a standard SGAgentType for grid games. This SGAgentTypeis assigned the type name
  • getTurkeyInitialState
  • setBoundaryWalls
    / Sets boundary walls of a domain. This method will add 4 solid walls (top left bottom right) to cre

Popular in Java

  • Creating JSON documents from java classes using gson
  • runOnUiThread (Activity)
  • getResourceAsStream (ClassLoader)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now