Create a game from Player instances

Any game in Matching can be made by manually creating instances of the Player class (or its child classes) and setting their preferences using those instances.

Consider the following instance of SM.

from matching import Player

suitors = [Player(name="A"), Player(name="B"), Player(name="C")]
reviewers = [Player(name="D"), Player(name="E"), Player(name="F")]

(A, B, C), (D, E, F) = suitors, reviewers

The preferences are then set using the set_prefs method of whichever Player class you’re using.

A.set_prefs([D, E, F])
B.set_prefs([D, F, E])
C.set_prefs([F, D, E])

D.set_prefs([B, C, A])
E.set_prefs([A, C, B])
F.set_prefs([C, B, A])

Finally, the game can be made by passing the lists of players directly.

from matching.games import StableMarriage

game = StableMarriage(suitors, reviewers)