forio Toggle navigation

World Manager

As discussed under the World API Adapter, a run is a collection of end user interactions with a project and its model. For building multiplayer simulations you typically want multiple end users to share the same set of interactions, and work within a common state. Epicenter allows you to create "worlds" to handle such cases.

The World Manager provides an easy way to track and access the current world and run for particular end users. It is typically used in pages that end users will interact with. (The related World API Adapter handles creating multiplayer worlds, and adding and removing end users and runs from a world. Because of this, typically the World Adapter is used for facilitator pages in your project.)

Using the World Manager

To use the World Manager, instantiate it. Then, make calls to any of the methods you need.

When you instantiate a World Manager, the world's account id, project id, and group are automatically taken from the session (thanks to the Authentication Service).

Note that the World Manager does not create worlds automatically. (This is different than the Run Manager.) However, you can pass in specific options to any runs created by the manager, using a run object.

The parameters for creating a World Manager are:

  • account: The Team ID in the Epicenter user interface for this project.
  • project: The Project ID for this project.
  • group: The Group Name for this world.
  • run: Options to use when creating new runs with the manager, e.g. run: { files: ['data.xls'] }.
  • run.model: The name of the primary model file for this project. Required if you have not already passed it in as part of the options parameter for an enclosing call.

For example:

  var wMgr = new F.manager.WorldManager({
     account: 'acme-simulations',
     project: 'supply-chain-game',
     run: { model: 'supply-chain.py' },
     group: 'team1'
  });

  wMgr.getCurrentRun();

Methods

getCurrentWorld

Returns the current world (object) and an instance of the World API Adapter.

Example

  wMgr.getCurrentWorld()
      .then(function(world, worldAdapter) {
          console.log(world.id);
          worldAdapter.getCurrentRunId();
      });

Parameters

  • userId: string (Optional) The id of the user whose world is being accessed. Defaults to the user in the current session.

  • groupName: string (Optional) The name of the group whose world is being accessed. Defaults to the group for the user in the current session.

getCurrentRun

Returns the current run (object) and an instance of the Run API Service.

Example

  wMgr.getCurrentRun('myModel.py')
      .then(function(run, runService) {
          console.log(run.id);
          runService.do('startGame');
      });

Parameters

  • model: string (Optional) The name of the model file. Required if not already passed in as run.model when the World Manager is created.