Skip to content
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

Negotiation Game deterministic state #1276

Open
Linwenye opened this issue Sep 8, 2024 · 1 comment
Open

Negotiation Game deterministic state #1276

Linwenye opened this issue Sep 8, 2024 · 1 comment
Labels
question Further information is requested

Comments

@Linwenye
Copy link

Linwenye commented Sep 8, 2024

Hi! As for the Negotiation game, I was expecting for the randomness of the initial game state, however, after conducting the code

    game = pyspiel.load_game("negotiation")
    state = game.new_initial_state()
    if state.is_chance_node():
        # Sample a chance event outcome.
        outcomes_with_probs = state.chance_outcomes()
        action_list, prob_list = zip(*outcomes_with_probs)
        action = np.random.choice(action_list, p=prob_list)
        state.apply_action(action)
        print(state)

It always return the same state. Why this happen?

@lanctot lanctot added the question Further information is requested label Sep 9, 2024
@lanctot
Copy link
Collaborator

lanctot commented Sep 9, 2024

Ah yes, that's because the game has chance mode kExplicitStochastic, which is explained in a comment here:

kSampledStochastic, // At least one chance node with non-deterministic

Essentially it means that there is a single chance outcome and the randomness is applied when you apply the action (so the RNG is stored internally in the game object).

If you don't pass in the rng_seed parameter, it defaults to -1 (see negotiation.h) and then uses the default one for the Mersenne twister, see here:

rng_(new std::mt19937(seed_ >= 0 ? seed_ : std::mt19937::default_seed)) {
(note: the documentation in the header should be updated, I'll fix that).

So it results in the same sequence of samples (after loading the game). Note that you don't need to load the game every time you want to create a new state (and you should only load the game once).

One fix is to set the seed yourself: e.g. pyspiel.load_game("negotiation(rng_seed=3279011)"). If you want the usual explict stochastic chance mode, there is another similar game called "bargaining" which does it using explicit stochastic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants