-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple Game Support #297
base: main
Are you sure you want to change the base?
Conversation
7eb3131
to
800794a
Compare
…networks in sequence. Fix tests.
A couple implementation notes:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like a reasonable compromise between backwards compatibility with the status quo and support for executing multiple games in a single experiment deployment, which is the main goal. We have lingering performance concerns, but it definitely makes sense to address those separately when and if we see them.
This PR pulls most of the game specific code from the
GridUniverse
experiment class into a newGame
class. The experiment class creates a number of networks and creates a Game instance for each network. It currently relies on standard behavior from Dallinger where theexperiment_repeats
value determines how many networks are created and theget_network_for_participant
method determines which network/game in which to add new participants.This implementation still runs the
game_loop
andsend_state_thread
tasks as gevent threads in the process running the web worker which happened to have/launch
run. I've tried to set things up so that the state passed when intializingGame
consists of simple python values objects. We may eventually be able to use themultiprocessing
module to launch eachGame
in a separate process.The experiment instance is currently responsible for receiving the all WebSocket messages and calls methods directly on Game instances based on the channel that messages were sent to. Moving to a multiprocessing model will require subscribing each game directly to the WebSocket channel (which should be more efficient) and providing a
send
method on theGame
class, or some intra-process communication mechanism.In order to support multiple games and waiting room like functionality I've added the following configuration options:
num_games
: The number of games to run in parallelquorum
: The total number of players needed before the waiting room closes and games can begin. Defaults tomax_participants
(the maximum number of players in a game).game_quorum
: The number of players needed before an individual game can start. Defaults tomax_participants
(the maximum number of players in a game).If you wanted to e.g. require all games be filled before starting any games you could set
quorum
tomax_particpants * num_games
. You can also disable the Dallinger waiting room by settingquorum
to0
. And you can have games start before they have filled up tomax_participants
by settinggame_quorum
to e.g.1
.Because the waiting room only works for the initial game, it's not possible to use the
pre_difi_question
feature on multiple concurrent games, and the waiting process looks a bit different between the first game and subsequent games.