Open
Conversation
7eb3131 to
800794a
Compare
Contributor
Author
|
A couple implementation notes:
|
jessesnyder
approved these changes
Nov 13, 2024
Contributor
jessesnyder
left a comment
There was a problem hiding this comment.
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.
…networks in sequence. Fix tests.
…sycopg2. Use a separate DB session for the game loop, use a shared DB engine for all games and sessions.
9f57bc6 to
cb7f03b
Compare
725c2fd to
f17bb5f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR pulls most of the game specific code from the
GridUniverseexperiment class into a newGameclass. 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_repeatsvalue determines how many networks are created and theget_network_for_participantmethod determines which network/game in which to add new participants.This implementation still runs the
game_loopandsend_state_threadtasks as gevent threads in the process running the web worker which happened to have/launchrun. I've tried to set things up so that the state passed when intializingGameconsists of simple python values objects. We may eventually be able to use themultiprocessingmodule to launch eachGamein 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
sendmethod on theGameclass, 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
quorumtomax_particpants * num_games. You can also disable the Dallinger waiting room by settingquorumto0. And you can have games start before they have filled up tomax_participantsby settinggame_quorumto e.g.1.Because the waiting room only works for the initial game, it's not possible to use the
pre_difi_questionfeature on multiple concurrent games, and the waiting process looks a bit different between the first game and subsequent games.