Class GameWorldModel

java.lang.Object
eu.iv4xr.framework.extensions.ltl.gameworldmodel.GameWorldModel
All Implemented Interfaces:
ITargetModel

public class GameWorldModel extends Object implements ITargetModel
An EFSM-like model of a game-world.
Author:
Samira, Wish.
  • Field Details

    • initialState

      public GWState initialState
    • history

      public List<Pair<GWState,​GWTransition>> history
      The history of the the states, stored in reverse order (the head of the list is the current state, the last state in the list is the oldest). Each k-th entry in the history is a pair (st,tr) where st is a state, and tr is the transition that was taken to get to that state from its previous state (so, that is the k+1 st state). The exception is the last state in the history, which is the model initial state, and has no tr.
    • zones

      public Set<GWZone> zones
    • blockers

      public Set<String> blockers
    • IS_OPEN_NAME

      public static String IS_OPEN_NAME
    • alpha

      public Function<GWObject,​Function<Set<GWObject>,​Void>> alpha
    • StressingMode

      public boolean StressingMode
  • Constructor Details

    • GameWorldModel

      GameWorldModel()
    • GameWorldModel

      public GameWorldModel(GWState initialState)
      Create an instance of GameWorldModel with the specified state as the initial state.
  • Method Details

    • addZones

      public GameWorldModel addZones(GWZone... zones)
      Add the given zones to this GameWorldModel. It returns this model.
    • markAsBlockers

      public GameWorldModel markAsBlockers(String... objectIds)
      Mark the specified objects (identified by their ids) as blockers. The method returns this model.
    • getZone

      public GWZone getZone(String zoneId)
    • registerObjectLinks

      public GameWorldModel registerObjectLinks(String switcherId, String... newAffectedIds)
      When we register (i,o1,o2,..) we are saying that interacting with the object i will affect o1, o2, ... These connections will be added to [objectlinks.

      The method returns this model.

    • isBlocker

      public boolean isBlocker(String id)
    • isBlocking

      public boolean isBlocking(String id)
    • zonesOf

      public Set<String> zonesOf(String objectId)
      Get the zone where a object is located. Note that a non-blocker will be in exactly one zone. A blocker is in either one or two zones.
    • inTheSameZone

      public boolean inTheSameZone(String obj1, String obj2)
      Check whether two objects are in the same zone.
    • canTravelTo

      public boolean canTravelTo(String destinationId)
    • travelTo

      public void travelTo(String destinationId)
    • canInteract

      public boolean canInteract(String targetId)
    • interact

      public void interact(String targetId)
    • reset

      public void reset()
      Reset this model to its initial-state.
      Specified by:
      reset in interface ITargetModel
    • reset

      public void reset(GWState newInitialState)
      Reset this model; use the given state as the new initial-state.
    • getCurrentState

      public GWState getCurrentState()
      Specified by:
      getCurrentState in interface ITargetModel
    • backTrackToPreviousState

      public boolean backTrackToPreviousState()
      Specified by:
      backTrackToPreviousState in interface ITargetModel
    • availableTransitions

      public List<ITransition> availableTransitions()
      Specified by:
      availableTransitions in interface ITargetModel
    • execute

      public void execute(ITransition tr)
      Specified by:
      execute in interface ITargetModel
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • save

      public void save(String filename) throws com.google.gson.JsonIOException, IOException
      Save this model as a JSON-object to a file. The alpha-component is not saved though, as it is a function.
      Throws:
      com.google.gson.JsonIOException
      IOException
    • loadGameWorldModelFromFile

      public static GameWorldModel loadGameWorldModelFromFile(String filename) throws IOException
      Read saved model (in JSON) from a file, and return the corresponding GameWorldModel object. The alpha-component is left null, as it cannot be saved, being a function.
      Throws:
      IOException