tucoopy.games.glove¶
Glove games.¶
In a glove game, each player \(i\) owns \(L_i\) left gloves and \(R_i\) right gloves. The coalition value is proportional to the number of pairs that can be formed:
\[ v(S) = u \min\left(\sum_{i \in S} L_i, \sum_{i \in S} R_i\right), \]
where \(u\) is the unit value per pair.
Examples:
>>> from tucoopy.games.glove import glove_game
>>> g = glove_game([1, 0], [0, 1])
>>> g.value(0b11)
1.0
glove_game ¶
glove_game(
left_gloves,
right_gloves,
*,
unit_value=1.0,
player_labels=None,
)
Construct a glove game (TU).
Each player \(i\) owns \(L_i\) left gloves and \(R_i\) right gloves. A coalition's value is:
\[v(S) = u_v \min\left(\sum_{i \in S} L_i, \sum_{i \in S} R_i\right)\]
where \(u_v\) is the unit value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
left_gloves | Sequence[int] | Number of left gloves owned by each player. | required |
right_gloves | Sequence[int] | Number of right gloves owned by each player. | required |
unit_value | float | Value per pair of gloves (default 1.0). | 1.0 |
player_labels | list of str | Optional labels for players. | None |
Returns:
| Type | Description |
|---|---|
Game | Cooperative game instance representing the glove game. |
Raises:
| Type | Description |
|---|---|
InvalidParameterError | If left_gloves and right_gloves have different lengths or fewer than 1 player. |
Examples:
>>> from tucoopy.games.glove import glove_game
>>> g = glove_game([1, 0], [0, 1])
>>> g.n_players
2
>>> g.value(3)
1.0