Skip to main content

An implementation of game theory of mind in a agent based framework following the implementation of Devaine, et al. (2017).

Project description

tomsup: Theory of Mind Simulation using Python

PyPI version pip downloads Code style: black python version license github actions pytest github actions docs github coverage CodeFactor

A Python Package for Agent-Based simulations. The package provides a computational eco-system for investigating and comparing computational models of hypothesized Theory of mind (ToM) mechanisms and for using them as experimental stimuli. The package notably includes an easy-to-use implementation of the variational Bayesian k-ToM model developed by Devaine, et al. (2017). This model has been shown able to capture individual and group-level differences in social skills, including between clinical populations and across primate species. It has also been deemed among the best computational models of ToM in terms of interaction with others and recursive representation of mental states. We provide a series of tutorials on how to implement the k-ToM model and a score of simpler types of ToM mechanisms in game-theory based simulations and experimental stimuli, including how to specify custom ToM models, and show examples of how resulting data can be analyzed.

📰 News

  • v. 1.1.5
    • New plotting features were added
    • Speed and memory improvements as well as support for multicore simulations 🏎
    • Added workflows to ensure dependencies are being updated
    • Minor bugfixes
  • v. 1.1.0
    • A speed comparison between the matlab implementation was introduced, showing the the tomsup implementation to be notably faster.
    • An extensive testsuite was introduced, for how to run it see the FAQ.
    • Code coverage was upped to 86% and code quality was raised to A.
    • A documentation site was introduced.
    • Added continiuous integration to ensure that the package always works as intended, with support for mac, windows and linux tests.
    • A new logo was introduced 🌟
  • v. 1.0.0
    • tomsup released its first version along with a preprint on psyarxiv
    • A series of tutorials was introduced to get you started with tomsup

🔧 Setup and installation

tomsup supports Python 3.6 or later. We strongly recommend that you install tomsup from pip. If you haven't installed pip you can install it from the official pip website, otherwise, run:

pip install tomsup 
Detailed instructions

You can also install it directly from GitHub by simply running:

pip install git+https://github.com/KennethEnevoldsen/tomsup.git

or more explicitly:

git clone https://github.com/KennethEnevoldsen/tomsup.git
cd tomsup
pip3 install -e .

Getting Started with tomsup

To get started with tomsup we recommend the tutorials in the tutorials folder. We recommend that you start with the introduction.

The tutorials are provided as Jupyter Notebooks. If you do not have Jupyter Notebook installed, instructions for installing and running can be found here.

Tutorial Content file name Open with
Documentation The documentations of tomsup
Introduction a general introduction to the features of tomsup which follows the implementation in the paper paper_implementation.ipynb Open In Colab
Creating an agent an example of how you would create new agent for the package. Creating_an_agent.ipynb Open In Colab
Specifying internal states a short guide on how to specify internal states on a k-ToM agent specifying_internal_states.ipynb Open In Colab
Psychopy experiment An example of how one might implement tomsup in an experiment Not a notebook, but a folder, psychopy_experiment Open in Github

🤔 Issues and Usage Q&A

To ask report issues or request features, please use the GitHub Issue Tracker. Otherwise, please use the discussion Forums.

FAQ

How do I test the code and run the test suite?

tomsup comes with an extensive test suite. In order to run the tests, you'll usually want to clone the repository and build tomsup from the source. This will also install the required development dependencies and test utilities defined in the requirements.txt.

pip install -r requirements.txt
pip install pytest

python -m pytest

which will run all the test in the tomsup/tests folder.

Specific tests can be run using:

python -m pytest tomsup/tests/<DesiredTest>.py

Code Coverage If you want to check code coverage you can run the following:

pip install pytest-cov

python -m pytest--cov=.
Does tomsup run on X?

tomssup is intended to run on all major OS, this includes Windows (latest version), MacOS (Catalina) and the latest version of Linux (Ubuntu). Please note these are only the systems tomsup is being actively tested on, if you run on a similar system (e.g. an earlier version of Linux) the package will likely run there as well.

How is the documentation generated?

Tomsup uses sphinx to generate documentation. It uses the Furo theme with a custom styling.

To make the documentation you can run:

# install sphinx, themes and extensions
pip install sphinx furo sphinx-copybutton sphinxext-opengraph

# generate html from documentations

make -C docs html

Using this Work

License

tomsup is released under the Apache License, Version 2.0.

Citing

If you use this work please cite:

@article{enevoldsen2020tomsup,
  title={tomsup: An implementation of computational Theory of Mind in Python},
  author={Enevoldsen, Kenneth C and Waade, Peter Thestrup},
  year={2020},
  publisher={PsyArXiv}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tomsup-1.1.7.tar.gz (40.6 kB view hashes)

Uploaded source

Built Distribution

tomsup-1.1.7-py2.py3-none-any.whl (42.4 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page