Skip to content

Commit

Permalink
Avalon Online Initial Release
Browse files Browse the repository at this point in the history
  • Loading branch information
sstepput committed Dec 7, 2023
1 parent 4f0d2c4 commit 3c56bf6
Show file tree
Hide file tree
Showing 44 changed files with 3,529 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
avalon_online/logs/*
__pycache__/
.htpasswd
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ We provide the dataset of 20 games in the _/dataset_ folder, where each game is
- Players have occasionally indicated their beliefs over other player's roles

## Running the Online version of Avalon
The online simulator will be released soon!
The online version of Avalon can be found in the folder _avalon_online_. In order to run the game, create a new conda environment with the _environment.yml_ file and run
```
python main.py
```
After that, open the displayed URL in your browser.

## Changelog
- [December 2023] Released initial Avalon online testbed
- [November 2023] Initial release of the dataset and project website
Binary file added avalon_online/avalon.db
Binary file not shown.
28 changes: 28 additions & 0 deletions avalon_online/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"server": {
"host": "0.0.0.0",
"port": 23001,
"debug": true
},
"flask": {
"secret_key": "OV5yRcfBODdwTWHH",
"flask_secret": "#FL^=Um$[xxKlDu0"
},
"game": {
"max_players": 6,
"roles": ["merlin", "percival", "servant-1", "servant-2", "morgana", "assassin"],
"turn_time": 200,
"quest_party_size": [2, 3, 4, 3, 4],
"vote_time": 30,
"persuasion_strategy": [
"Assertion",
"Questioning",
"Suggestion",
"Agreement",
"Logical Deduction",
"Compromise/Concession",
"Critique/Opposition",
"Appeal/Defense"
]
}
}
173 changes: 173 additions & 0 deletions avalon_online/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
name: emnlp
channels:
- defaults
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2023.01.10=h06a4308_0
- cudatoolkit=11.8.0=h6a678d5_0
- ld_impl_linux-64=2.38=h1181459_1
- libffi=3.4.4=h6a678d5_0
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=1.1.1t=h7f8727e_0
- pip=23.0.1=py39h06a4308_0
- python=3.9.16=h7a1cb2a_2
- readline=8.2=h5eee18b_0
- setuptools=66.0.0=py39h06a4308_0
- sqlite=3.41.2=h5eee18b_0
- tk=8.6.12=h1ccaba5_0
- wheel=0.38.4=py39h06a4308_0
- xz=5.4.2=h5eee18b_0
- zlib=1.2.13=h5eee18b_0
- pip:
- absl-py==1.4.0
- accelerate
- aiofiles==23.1.0
- aiohttp==3.8.4
- aiosignal==1.3.1
- altair==5.0.1
- anyio==3.7.0
- appdirs==1.4.4
- async-timeout==4.0.2
- attrs==23.1.0
- beautifulsoup4==4.12.2
- bert-score==0.3.13
- bidict==0.22.1
- bitsandbytes==0.39.0
- blinker==1.6.2
- cachetools==5.3.1
- certifi==2023.5.7
- chardet==5.1.0
- charset-normalizer==3.1.0
- click==8.1.3
- cmake==3.26.3
- colorama==0.4.6
- contourpy==1.0.7
- cycler==0.11.0
- datasets==2.12.0
- dill==0.3.6
- distlib==0.3.6
- docker-pycreds==0.4.0
- evaluate==0.4.0
- exceptiongroup==1.1.1
- fastapi==0.95.2
- ffmpy==0.3.0
- filelock==3.12.0
- flask==2.3.2
- flask-htpasswd==0.5.0
- flask-login==0.6.2
- flask-socketio==5.3.4
- flask-wtf==1.1.1
- fonttools==4.39.4
- frozenlist==1.3.3
- fsspec==2023.5.0
- gitdb==4.0.10
- gitpython==3.1.31
- gradio==3.32.0
- gradio-client==0.2.5
- h11==0.14.0
- hashids==1.3.1
- httpcore==0.17.2
- httpx==0.24.1
- huggingface-hub==0.14.1
- idna==3.4
- importlib-metadata==6.6.0
- importlib-resources==5.12.0
- itsdangerous==2.1.2
- jinja2==3.1.2
- joblib==1.2.0
- jsonschema==4.17.3
- kiwisolver==1.4.4
- linkify-it-py==2.0.2
- lit==16.0.5
- lxml==4.9.2
- markdown-it-py==2.2.0
- markupsafe==2.1.2
- matplotlib==3.7.1
- mdit-py-plugins==0.3.3
- mdurl==0.1.2
- mpmath==1.3.0
- multidict==6.0.4
- multiprocess==0.70.14
- networkx==3.1
- nltk==3.8.1
- numpy==1.24.3
- nvidia-cublas-cu11==11.10.3.66
- nvidia-cuda-cupti-cu11==11.7.101
- nvidia-cuda-nvrtc-cu11==11.7.99
- nvidia-cuda-runtime-cu11==11.7.99
- nvidia-cudnn-cu11==8.5.0.96
- nvidia-cufft-cu11==10.9.0.58
- nvidia-curand-cu11==10.2.10.91
- nvidia-cusolver-cu11==11.4.0.1
- nvidia-cusparse-cu11==11.7.4.91
- nvidia-nccl-cu11==2.14.3
- nvidia-nvtx-cu11==11.7.91
- orjson==3.8.14
- packaging==23.1
- pandas==2.0.1
- passlib==1.7.4
- pathtools==0.1.2
- peft
- pillow==9.5.0
- platformdirs==3.5.1
- pluggy==1.0.0
- protobuf==4.23.2
- psutil==5.9.5
- pyarrow==12.0.0
- pydantic==1.10.8
- pydub==0.25.1
- pygments==2.15.1
- pyjwt==2.7.0
- pyparsing==3.0.9
- pyproject-api==1.5.1
- pyrsistent==0.19.3
- python-dateutil==2.8.2
- python-engineio==4.4.1
- python-multipart==0.0.6
- python-socketio==5.8.0
- pytz==2023.3
- pyyaml==6.0
- regex==2023.5.5
- requests==2.31.0
- responses==0.18.0
- rouge-score==0.1.2
- safetensors==0.3.1
- scikit-learn==1.2.2
- scipy==1.10.1
- semantic-version==2.10.0
- sentencepiece==0.1.99
- sentry-sdk==1.24.0
- setproctitle==1.3.2
- six==1.16.0
- smmap==5.0.0
- sniffio==1.3.0
- soupsieve==2.4.1
- starlette==0.27.0
- sympy==1.12
- threadpoolctl==3.1.0
- tinydb==4.7.1
- tokenizers==0.13.3
- tomli==2.0.1
- toolz==0.12.0
- torch==2.0.1
- tox==4.5.2
- tqdm==4.65.0
- transformers
- triton==2.0.0
- typing-extensions==4.6.2
- tzdata==2023.3
- uc-micro-py==1.0.2
- urllib3==1.26.16
- uvicorn==0.22.0
- virtualenv==20.23.0
- wandb==0.15.2
- websockets==11.0.3
- werkzeug==2.3.4
- wtforms==3.0.1
- xxhash==3.2.0
- yarl==1.9.2
- zipp==3.15.0
70 changes: 70 additions & 0 deletions avalon_online/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/env python

# Copyright 2023 by Simon Stepputtis, Carnegie Mellon University
# All rights reserved.
# This file is part of the Avalon-NLU repository,
# and is released under the "MIT License Agreement". Please see the LICENSE
# file that should have been included as part of this package.

import json
from flask import Flask
from hashids import Hashids
import time
from threading import Semaphore
from flask_htpasswd import HtPasswdAuth
from flask_socketio import SocketIO
import werkzeug
from src.clogin import VLogin
from src.cregister import VRegister
from src.clobby import VLobby
from src.cgame import NSGame, VGame
from src.manager import Manager
from flask_login import LoginManager
from src.user import User

def main():
config = None
with open("config.json", "r") as fh:
config = json.load(fh)

socketio = SocketIO()
manager = Manager(config, socketio)

app = Flask(__name__, template_folder="./templates")
# app.wsgi_app = werkzeug.middleware.shared_data.SharedDataMiddleware(socketio, app.wsgi_app)
app.config['FLASK_HTPASSWD_PATH'] = './templates/.htpasswd'
app.config['FLASK_SECRET'] = config["flask"]["flask_secret"]
# htpasswd = HtPasswdAuth(app)

app.config['SECRET_KEY'] = config["flask"]["secret_key"]
app.debug = config["server"]["debug"]

login_manager = LoginManager()
login_manager.login_view = '/'
login_manager.session_protection = "strong"
login_manager.init_app(app)

@login_manager.user_loader
def load_user(session_token):
return manager.getUserObject(session_token)

socketio.init_app(app)

# Define Routs
# Register
app.add_url_rule("/register", view_func=VRegister.as_view("register", config, manager))
# Login
app.add_url_rule("/", view_func=VLogin.as_view("login", config, manager))
# Lobby
app.add_url_rule("/lobby", view_func=VLobby.as_view("lobby", config, manager))
# Game
app.add_url_rule("/game", view_func=VGame.as_view("game", config, manager))
nsgame = NSGame("/game")
nsgame.setup(config, manager)
socketio.on_namespace(nsgame)

socketio.run(app, port=config["server"]["port"], debug=config["server"]["debug"], host=config["server"]["host"])


if __name__ == '__main__':
main()
Empty file added avalon_online/src/__init__.py
Empty file.
Loading

0 comments on commit 3c56bf6

Please sign in to comment.