oTree Forum >

randomly rematch participants in ~some~ rounds

#1 by lucas

# [supergames with random rematching](https://github.com/lucasreddinger/otree-supergame-rematching)

Here I have taken the "supergames" app from [otree-snippets](https://www.otreehub.com/projects/otree-snippets/). I attempt to add random rematching between supergames. I also add a variable to subsession that marks for debugging purposes when `subsession.group_randomly()` is executed. These changes are made in `__init__.py`.

  - expected behavior:
      - for each round with `subsession.period == 1`
            randomly rematch participants
            mark `subsession.rematched = True`
      - else
            mark `subsession.rematched = False`
  - actual behavior:
      - for every round, participants are rematched.
      - however `subsession.rematched` is changed as expected!

[Please see my commit 174a979](https://github.com/lucasreddinger/otree-supergame-rematching/commit/174a97903c9846140ad9ea91bf30d790523b5fd8

Thank you for any and all of your help with this!

#2 by lucas

I assumed that groups stayed the same by default (per the official docs). Looking at the otree-core, I cannot figure out why the conditional statement isn't being respected.

But this is a workaround:

```
    if subsession.period == 1:
        subsession.group_randomly()
    else:
        subsession.group_like_round(subsession.round_number - 1)
```

The community docs can be handy, even if they're outdated:
https://otreecb.netlify.app/intro.html

Write a reply

Set forum username