Contact the Author
Simple Game Lab
News | Features | Documentation | Embedding | Contribute | Download | Acknowledgements | License

Welcome to the Simple Game Laboratory, a playground for Simple Games and Multiple Weighted Voting Games in particular. The aim of this project is to solve some problems and answer questions which naturally arise when working with simple games.

or
(May take a few seconds to load; "Enter" opens the lab in a new window)

As a web application entirely written in JavaScript the laboratory works out of the box without any additional software except a modern web browser like Mozilla's Firefox or Google's Chrome.

News

  • March 2012: Released version 2.1 of the library. Changes include:
    • Additional example for the US Federal Legal System.
    • Added input of Boolean vectors.
    • Improved computation of shift-minimal winning and shift-maximal losing coalitions/models.
    • Improved support for random games.
    • Improved counting and enumeration of models.
    • Added benchmark script. See embed/examples/benchmark/.
    • Fixed bugs. In some rare cases the QOBDDs for the shift-minimal winning and shift-maximal losing coalitions are incorrect in the previous version(s).
  • Sept. 2011: Released version 2 of the library.

Features

Given any number of weighted voting games, the laboratory can handle any simple games built from them using conjunction and disjunction. That includes multiple weighted voting games.

Features include but are not limited to:

  • Efficient representation of simple games by using quasi-reduced binary decision diagrams (QOBDDs).
  • Load simple games from (multiple) weighted voting games, lists of minimal winning coalitions and Boolean expressions.
  • Count and list the (models of) the winning, minimal winning, shift-minimal winning coalitions, the blocking coalitions (dual game) and the losing, maximal losing and shift-maximal losing coalitions.
  • Perform tests if a game is complete/swap-robust (with counterexample if not), directed, consecutive and determine its symmetry classes (types).
  • Test if a game is homogeneous.
  • Perform tests if a game is strong, proper and decisive, respectively.
  • Partial test if a game is weighted (with counterexample if not).
  • Determination of dummy and veto players and test for dictatorship.
  • Computation of Banzhaf, Shapley-Shubik, Holler-Packel, Deegan-Packel and Shift-Power index.
  • Test of being a weighted voting game. Export of the corresponding linear program.
  • Improved embedding of the library into external projects. See Embedding.
Definitions for the terms are given in the help (opens in new window).

Documentation

There is little documentation on the terms used in the laboratory. See here (opens in new window).

There is currently no source code documentation available. However, important parts of the source code are documented well. A good starting point is the file js/core/SimpleGame.js and the constructor SimpleGame.

Embedding into external Projects

It it sometimes convenient to use the functionality of the laboratory without a web browser from the command line or in an external program, for instance, on a web server. There are both libraries such as Mozilla SpiderMonkey and Google v8 which can be used to embed JavaScript into other programming languages such as C or C++ as well as JavaScript interpreters or shells such as the JavaScript shell which is shipped with Mozilla SpiderMonkey.

At this point we will give a short example how the latter shell can be used to load the laboratory and do tasks. We assume you have already installed the JavaScript shell as js on your system. The laboratory comes with a dedicated file embed/lab.js which can be used here. The file contains a singleton called Lab which has a init method which has to be called to load the library. The init function will load any files necessary (including external libraries such as closure and jshashtable). The arguments to init are the directories of the libraries and an optional load function that has to be used to load the .js files. By default the global function load is used which is provided by some JavaScript shells. For example, the library can be initialized using the lines:

var src_dir = "/home/stb/workspace/lab";
Lab.init(src_dir, src_dir, src_dir);
					
To read a file, SpiderMonkey' shell provides a function read(filename). The following code loads a game from a file and writes the models of its shift-minimal winning coalitions to the standard output. The format is the same as in the online version.
try {
	var gameStr = read (<your-file.game>);
	
	// Parse and load the game. The returned object is of type SimpleGame.
	var game = parse_mwvg (gameStr);
	
	// List all models of the shift-minimal winning coalitions.
	var models = game.getShiftMinWinModels ();
	for (var i in models) {
		print ('(' + models[i] + ')');
	}
}
catch (e) {
	if (e instanceof ParserException) {
		print ("Unable to parse game. Reason: " + e);
	}
	else {
		print ("Unknown error. Details: " + e);
	}
}
					
From the command line, use:
$ js -f /home/stb/workspace/lab/embed/lab.js -f <your-file.js>
					
Two rules of thumb for SpiderMonkey. 1. If SpiderMonkey says "out of memory", the internal runtime created by the shell is too small (160 MiB by default). Unfortunately, this value cannot be changed dynamically such that the shell has to be recompiled in order to change it. E.g., you could include limits.h and pass UINT_MAX to JS_NewRuntime. 2. It usually is much faster to enable the optimizations offered by the JavaScript shell. See for details:
$ js --help
					

Contribute

There are some ways to contribute to this project:

  • Send a bug report.
  • Request a feature.
  • Contribute new features.
Any support is very much appreciated. Contact the author for details.

Download the Source Code

Even though this software is written in Java Script, the files available online may be compressed and/or compiled using, for instance, the Closure Compiler, so that they are hard to read and understand for humans.

The following archive(s) contain all source files necessary to run the laboratory on your computer, except third-party libraries.

FilenameDateSize
simple_games_lab-2.1.tar.bz2 08/03/2012146 KiB
simple_games_lab-2.0.tar.bz2 14/09/2011139 KiB
simple_games_lab-1.0.tar.bz2 25/03/2011124.5 KiB
In order to get the laboratory working, extract the archive somewhere, say in /home/your_name/. On Windows it would be something like C:\Users\YourName\. The archive contains a directory named simple_games_lab-<version> where <version> is the laboratory's version, for instance, 1.0. Now perform the following steps:
  • Change working directory to simple_games_lab-<version>/.
  • Checkout the latest version of the Closure Library using Subversion: >
    svn checkout http://closure-library.googlecode.com/svn/trunk/ closure-library
  • Download a recent version of RGraph and extract it into the current working directory. This should create a directory named RGraph/.
That's it. Now open the file
file:///home/your_name/simple_games_lab-<version>/index.html
in your web browser.

Acknowledgements

This project is supported by the German Research Foundation (Grant BE 4206/1-1) and it is part of SSEAC.

We would also thank the authors of the following third-party libraries which are used:

License

This software is licensed under the GNU General Public License Version 3 or later. Third-party libraries and code may have its own license.

Last Updated: 08/03/2012