Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

simpl-calc-model - example single-player simulation model service.

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

Install simpl-calc-model

$ git clone https://github.com/simplworld/simpl-calc-model.git
$ cd simpl-calc-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-calc game in the API.

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

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

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

$ ./manage.py create_default_env

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

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

$ exit
$ docker-compose down
$ docker-compose up

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

Game `simpl-calc` installed in 2.063s.

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

Local Setup Without Docker

Create a virtual environment and install Python dependencies

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

Run model service

$ export DJANGO_SETTINGS_MODULE=simpl_calc_model.settings
$ ./manage.py run_modelservice

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

$ ./manage.py 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 ./manage.py run_modelservice --print-config > config.json
  2. Edit config.json to remove the entire {"type": "guest", ...} stanza and final line
  3. Run crossbar service:
    ./manage.py run_modelservice --config=./config.json --loglevel info --settings=simpl_calc_model.settings
  4. In a separate terminal, run guest service:
    HOSTNAME=localhost PORT=8080 ./manage.py run_guest --settings=simpl_calc_model.settings

Run unit tests

$ pytest

Development commands:

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

  1. Creates the simpl-calc game with one phase (Play) and one role (Calculator).
  2. Adds a 'default' run..
  3. Adds 1 leader ('leader@calc.edu'/'leader') to the run.
  4. Adds 2 players to the run ('s#@calc.edu'/'s#' where # is between 1..2. Each player has a private scenario and period 1.
  5. The run is set to 'Play' phase

execute:

$ ./manage.py 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:

$ ./manage.py create_default_env --reset

2 - To submit a decision on a scenario:

$ ./manage.py submit_decision -s <scenario_id> -d <decision>

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.

About

Model service of simpl-calc example game using Simpl framework

Resources

License

Releases

No releases published

Packages

No packages published