MatchMaker.match_chain()#

MatchMaker.match_chain(include_previous: bool = True, **spectimes) Group[source]#

Offers prioritized matchmaking based on multiple specs.

Imagine that you have two ParallelSpec group specifications. Spec 1 requires five participants to be active, while Spec 2 only requires two. You may wish to first try matching based on Spec 1 for some time and move on to Spec 2 only when it becomes incresingly clear that there are not enough participants present to fill the bigger spec. This is what this method is for. You specify a schedule of time boxes that are reserved for specific specs.

Parameters
  • include_previous (bool) – If True, earlier specs will still be available for matching in later time boxes. If there are enough participants waiting for two specs, the MatchMaker selects a random spec for matching. Defaults to True.

  • **spectimes – Specifications of spec timeboxes. Specified by specname=time, where time is the length of the spec’s time box in seconds and specname is the spec’s name. For the last spec, the value for time is irrelevant, as it will be included until the MatchMaking process times out. It should be set to None. You can select any number of specs, but only specs that are available to the MatchMaker.

Raises

NoMatch – If a single matching effort was unsuccesful. This exception gets handled by WaitingPage and is part of a normal matching process.

Returns

The group object.

Return type

Group

Examples

In this example, the MatchMaker will try to form a group based on spec2 for the first three minutes of the matchmaking process. Once the first active participant has waited for more than three minutes without a successfull match, spec1 will be included:

import alfred3 as al
import alfred3_interact as ali

exp = al.Experiment()

@exp.setup
def setup(exp):
    spec1 = ali.ParallelSpec("a", "b", nslots=10, name="spec1")
    spec2 = ali.ParallelSpec("a", "b", "c", nslots=10, name="spec2")
    exp.plugins.mm = ali.MatchMaker(spec1, spec2, exp=exp)

@exp.member
class Match(ali.WaitingPage):

    def wait_for(self):
        group = self.exp.plugins.mm.match_chain(spec2=3*60, spec1=None)
        self.exp.plugins.group = group
        self.exp.condition = group.data.spec_name
        return True

@exp.member
class Success(al.Page):

    def on_first_show(self):
        group = self.exp.plugins.group
        role = group.me.role
        cond = self.exp.condition

        self += al.Text(f"Successfully matched to role '{role}' in condition '{cond}'")