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
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
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionWorldModel(AssetBuilder builder) Constructs a story world model from the assets defined in an asset builder.WorldModel(World world) Constructs a story world model using the assets defined in an existing world.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 astory world. -
Method Summary
Modifier and TypeMethodDescriptionabstract StatusReturns the initial state of the story world for a given role as a status object.abstract Statustransition(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.Methods inherited from class World
contains, contains, contains, contains, getAction, getAction, getAction, getActions, getEnding, getEnding, getEnding, getEndings, getEntities, getEntity, getEntity, getName, getPlayer, getVariable, getVariable, getVariable, getVariables, requireAction, requireAction, requireAction, requireEnding, requireEnding, requireEnding, requireEntity, requireEntity, requireVariable, requireVariable, requireVariable, toString, validate, validate, validate, validate, validate
-
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 astory world.- Parameters:
name- a unique name for the story worldentities- a collection of objects that exist in the worldvariables- a collection of variables whose values can change and whose current values reflect the current state of the worldactions- a collection of ways the world state can changeendings- 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
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
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
Returns the initial state of the story world for a given role as a status object. For thegame master, the initial status should completely and accurately define the initial state of all variables and entities. For theplayer, 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 nohistory.- Parameters:
role- the role whose initial status is desired- Returns:
- the initial status of the story world for that role
-
transition
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 samerole as the first status argument. Since thegame mastershould 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 theplayer, 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' participantactual- the actual current status of the story worldturn- the turn to be taken- Returns:
- the new story world status as perceived by the status' participant
-