Class WorldModel

java.lang.Object
edu.uky.cs.nil.tt.world.World
edu.uky.cs.nil.tt.world.WorldModel
All Implemented Interfaces:
Named
Direct Known Subclasses:
LogicalWorld

public abstract class WorldModel extends World
A world model is an implementation of a story world that contains the necessary logic to simulate how turns change the story state. World models are not meant to be transmitted to the participants of a session. Their logic is meant to be simulated by the server only.
Author:
Stephen G. Ware
  • Constructor Details

    • WorldModel

      public WorldModel(String name, Collection<Entity> entities, Collection<Variable> variables, Collection<Action> actions, Collection<Ending> endings)
      Constructs a story world model with the assets needed to construct a story world.
      Parameters:
      name - a unique name for the story world
      entities - a collection of objects that exist in the world
      variables - a collection of variables whose values can change and whose current values reflect the current state of the world
      actions - a collection of ways the world state can change
      endings - a collection of ways a story in this world can end
      Throws:
      IllegalArgumentException - if the provided assets do not meet the required format, such as two assets of the same type having the same name
    • WorldModel

      public WorldModel(AssetBuilder builder)
      Constructs a story world model from the assets defined in an asset builder.
      Parameters:
      builder - the asset builder that defines the assets to be used in this story world
      Throws:
      IllegalArgumentException - if the provided assets do not meet the required format, such as two assets of the same type having the same name
    • WorldModel

      public WorldModel(World world)
      Constructs a story world model using the assets defined in an existing world.
      Parameters:
      world - the world whose assets will be copied
  • Method Details

    • start

      public abstract Status start(Role role)
      Returns the initial state of the story world for a given role as a status object. For the game master, the initial status should completely and accurately define the initial state of all variables and entities. For the player, the initial status should should define the initial state of all variables and entities that the player knows about at the start of the story. The initial status should have no history.
      Parameters:
      role - the role whose initial status is desired
      Returns:
      the initial status of the story world for that role
    • transition

      public abstract Status transition(Status status, State actual, Turn turn)
      Given the current status of a story world (actual or perceived), the actual current status of a story world, and a turn, this method simulates that turn and returns the new perceived status of the story world. The status returned will be for the same role as the first status argument. Since the game master should always know the actual status of the story world, when calculating a new status for the game master, the first two status arguments should be the same. When calculating a new status for the player, the first status argument should be the player's perceived status and the second should be the actual status available to the game master. The status returned will be the new status as perceived by that role (the new actual status for the game master or the new perceived status for the player).
      Parameters:
      status - the current status of the story world as perceived by the status' participant
      actual - the actual current status of the story world
      turn - the turn to be taken
      Returns:
      the new story world status as perceived by the status' participant