Add param_social_dilemma: parameterized N-player social dilemma game#1482
Open
sriramsowmithri9807 wants to merge 7 commits intogoogle-deepmind:masterfrom
Open
Add param_social_dilemma: parameterized N-player social dilemma game#1482sriramsowmithri9807 wants to merge 7 commits intogoogle-deepmind:masterfrom
sriramsowmithri9807 wants to merge 7 commits intogoogle-deepmind:masterfrom
Conversation
…payoffs, and Axelrod-style bots - Implemented flexible N-player simultaneous-move game (N >= 2) - Added dynamic payoff matrices with configurable change probability - Implemented stochastic rewards with Gaussian noise - Created 7 Axelrod-style bots (TitForTat, GrimTrigger, Pavlov, etc.) - Added comprehensive unit tests (21 test cases total) - Included example scripts for MARL usage and bot tournaments - Added documentation (README and implementation summaries) Features: - Variable number of agents (default: 3) - Dynamic and non-stationary payoff structures - Optional reward noise for robustness studies - Full Python API exposure for all parameters - Compatible with OpenSpiel's simultaneous-move game API Files added: - Core game implementation and tests - Axelrod-style bots and bot tests - Usage examples and tournament demonstrations - Documentation files
- Changed payoff_matrix default from None (kUnset) to 'default' (kString) so pyspiel.load_game() accepts custom payoff matrix strings - Added ast.literal_eval parsing with dtype=np.float64 for custom matrices - Added proper error handling for malformed payoff matrix input - All 14 game tests, 8 bot tests, and example script pass (Python 3.13.5)
Collaborator
|
Does this replace #1458? |
Author
|
Yes sir!! |
…n pyspiel_test and CMakeLists - Rename 'num_players' parameter to 'players' in param_social_dilemma to match OpenSpiel convention (fixes test_multiplayer_game failure) - Add python_param_social_dilemma to EXPECTED_MANDATORY_GAMES in pyspiel_test.py - Register param_social_dilemma tests in python/CMakeLists.txt - Generate playthrough file for integration tests - Update all tests, examples, and docs to use new parameter name
lanctot
requested changes
Feb 20, 2026
Collaborator
lanctot
left a comment
There was a problem hiding this comment.
Great, thanks. Tests are now passing.
A few changes please:
- AFAICT this is the param_social_dilemma implementation. Can you edit the name of the PR to reflect that?
- Please remove IMPLEMENTATION_SUMMARY.md and PR_SUMMARY.md
- Please follow step 9 of the "Adding a game" guide here (https://github.com/google-deepmind/open_spiel/blob/master/docs/developer_guide.md#adding-a-game); specifically, run pylint using the Google pylintrc file until there are no more lint errors.
Thanks!
| self.assertEqual(legal_actions, [0, 1, 2]) | ||
|
|
||
| def test_action_to_string(self): | ||
| game = pyspiel.load_game("python_param_social_dilemma") |
Collaborator
There was a problem hiding this comment.
Can you make all the files 2-space indent to be consisten with the rest of the OpenSpiel code base?
…iles - Convert param_social_dilemma.py to 2-space indentation - Convert param_social_dilemma_test.py to 2-space indentation - Fix pylint errors: dangerous-default-value, raise-missing-from, unused-argument, protected-access - Remove IMPLEMENTATION_SUMMARY.md and PR_SUMMARY.md - All files pass pylint with Google pylintrc
TypeError / SpielError when passing custom payoff matrices via pyspiel.load_game() in the param_social_dilemma game. Closes #1431
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.
Changes
1. open_spiel/python/games/param_social_dilemma.py
import astfor safe string parsing"payoff_matrix": None→"payoff_matrix": "default"in_DEFAULT_PARAMSso pyspiel recognizes it as a validkStringparameter type"default"string instead ofNoneast.literal_evalparsing with explicitdtype=np.float64for custom payoff matrix stringsValueErrorfor malformed input2. open_spiel/python/games/param_social_dilemma_test.py
custom_payoff.tolist()with str() to pass as string3. open_spiel/python/examples/param_social_dilemma_example.py
custom_payoff.tolist()with str() to pass as stringTesting