Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

simpl-div-model - example multi player simulation model service.

Python Setup (assumes Python 3.6 and simpl-games-api server running)

Install simpl-div-model

$ git clone
$ cd simpl-div-model

Local Docker Setup

The Simpl API server needs to be started first to create the simpl bridge network.

Install simpl-games-api master and run it in docker-compose so that it exposes itself as hostname api on port 8100.

You also need to have a is_staff=True user in the simpl-games-api database that corresponds to the SIMPL_GAMES_AUTH setting used here.

After you clone the repo, run:

$ docker-compose up

this will create the Docker image and run it. The first time you run it it will error as it can't find the simpl-div game in the API.

In a separate terminal, create a shell into the simpl-div-model container by running:

$ docker-compose run --rm model.backend bash

Once you are in the container shell, run this command:

$ ./ create_default_env

You should see this create the 'simpl-div' game, phases, users, etc.

Exit from the shell then stop and restart the docker container by running these commands:

$ docker-compose down
$ docker-compose up

You should now see a startup log message to the effect of:

Game `simpl-div` installed in 2.063s.

This means the simpl-div-model is able to successfully communicate with the API.

Local Setup Without Docker

Create a virtual environment and install Python dependencies

$ mkvirtualenv simpl-div-model
$ pip install -r requirements.txt

Run model service

$ export DJANGO_SETTINGS_MODULE=simpl_div_model.settings
$ ./ run_modelservice

If you need some serious debugging help, the model_service includes the ability to do

$ ./ run_modelservice --loglevel=debug

Which will turn on verbose debugging of the Autobahn/Crossbar daemon to help debug interactions between the browser and model service backend.

Run model service as 2 processes

  1. Get a copy of the currently in use crossbar configuration by running ./ run_modelservice --print-config > config.json
  2. Edit config.json to remove the entire {"type": "guest", ...} stanza and final line
  3. Run crossbar service:
    ./ run_modelservice --config=./config.json --loglevel info --settings=simpl_div_model.settings
  4. In a separate terminal, run guest service:
    HOSTNAME=localhost PORT=8080 ./ run_guest --settings=simpl_div_model.settings

Run unit tests

$ export DJANGO_SETTINGS_MODULE=simpl_div_model.settings
$ py.test

Development commands:

1 - To setup up database for simpl-div development use:

  1. Creates the simpl-div game with two phases (Play and Debrief) and two roles ("Dividend" and "Divisor").
  2. Adds a 'default' run..
  3. Adds 1 leader (''/'leader') to the run.
  4. Adds 2 players to the run (''/'s#' where # is between 1..2. Each player has a private scenario and period 1.
  5. The run is set to 'Play' phase


$ ./ create_default_env

To make it easier to recreate the default run you can pass the --reset option to delete the default run and recreate it from scratch like this:

$ ./ create_default_env --reset

To create a run with a non-default name, use:

./ create_default_env -n <name>

where: name is the run name (default is 'default') and the base of player email ids (default is 's')

Modelservice Profiling

Run modelservice profiling tests locally

  1. Run simpl-games-api modelservice
  2. Run simpl-div-model modelservice

Create and activate a virtual environment:

$ mkvirtualenv simpl-div-model
$ pip install -r requirements.txt

Create a test run named 'a' with 4 players named after the run (e.g. run 'a' with players '', etc)

$ ./ create_default_env -n a

To run each player test once for each user in the emails/emails-4.txt file, run:

$ -m game.profilers -u emails/emails-4.txt -g 1

to launch a separate profiling task for each email in the file:

./ profile -m game.profilers -g 1 -w 4 --log-level error --user-email
./ profile -m game.profilers -g 1 -w 4 --log-level error --user-email
./ profile -m game.profilers -g 1 -w 4 --log-level error --user-email
./ profile -m game.profilers -g 1 -w 4 --log-level error --user-email

Once all tasks complete, message will be printed out indicating how many seconds it took to run all profile tests

If the run is not configured to submit new decisions for each profile user, error messages will be printed out.

Before rerunning the profiling test, recreate the test run:

./ create_default_env -n a --reset

Copyright © 2018 The Wharton School,  The University of Pennsylvania 

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.


Model service of simpl-div example game using Simpl framework




No releases published


No packages published