Functionality details -- Important basics about SeSAm you'd like to know.
Order of execution
- Initialization is done when a new Simulation Run or (later) an Agent is created.
- If the world is configured to update first it is updated first.
- Entities are updated in random order
- Analysis are updated in the order they are listed.
Interpretation of activity graphs (reasoning engine)
Every time step the following program is executed for every agent:
Start with activity (last Activity from last update of the agent)
- Test all outgoing rules of activity
- If no rule fires
- If activity takes time (denoted by the small clock)
- then: stop (-- next agent is updated)
- else: goto 1
Beware of endless loops, when using decision nodes or time-less activities!
Variable initialization and update ("next values") order
"Next value" variables are updated in the order the variables appear in the list of variables (tab of an entity). Without adjustments, the order corresponds to the order in wich features/variables were added to the entity. However:
- There is (still) a quirky dependece on the variable type: The update method of the class AbstractObject (sesam.mas.entity.object.AbstractObject.java) first calls all "feature updates" - these are not user features and their variables, but java-level plugins that may have additional things to update. Then the bodyUpdate is called. All the nextValue functions are associated with bodyVariables and thus appear in the bodyUpdate (in sesam.mas.entity.body.Body.java). This function first collects all variables that are neither double nor int and updates them in the given order, then all variables of type double are updated and then all integer variables. The order in the body is preserved, just like taking out all variables of a given type.
- To rearrange the order according to a new sorting of the variable in the user feature, you can remove and re-add the features. However, Obs:
- Removing a feature from an agent discards any agent or situation specific "own default values". (Copy/backup those beforehand!)
- To avoid hickups, do this with a freshly opened model and close the agents window in between removing features, go slowly on re-adding features, and watch for error messages on stderr ("Global Assert" enabled).
- Changing the feature order in a world did cause the compilation of simulations to fail, at least until saving and reopening the model. (May only happen with a world contained in a simulation definition?)
Spacial Directions and Coordinate System
The coordinate system of SeSAm is different to GIS-based coordinate systems, but equal to the coordinate system that a programmer is used :-( : The origin x=0,y=0 lies in the upper, left corner of the map. Growing x-numbers means moving to the right, growing y-number means moving down the map. Using the primitive getMapDimension one gets the size of the map in the form of the maximum x and y-position. Another issue that seems to be contra-intuitive for many users is the direction of spatial infos of agents: direction = 0 means that the agent is heading directly to the right. It next movement will happen with direction dx=1,dy=0. Direction is represented according to angular degrees between 0 - 360 (with 360=0) in clockwise direction. That means a direction of 90 means that the agent is heading towards south, 180 means towards east, 270 north and 360 again to the right, west.