What do I have to learn to solve this role assignment problem?

I need guidance to develop a program in Python. I wouldn’t exactly need the code to develop it, but I would be interested to know what I have to learn well, some tutorial, some course or what algorithm could help me to solve it and program it. I expose what I want to program:

The program consists of assigning different roles to soccer players defending a corner. The assignment will depend on 2 factors: their defensive qualities and the offensive level of the attackers. There are 3 defensive roles for ‘my’ players:

  • Individual marking (Role A)
  • Zonal marking (Role B)
  • Front of the box (Role C)

In total I have 10 players and 5 have Role A, 3 have Role B and 2 have Role C. On the one hand, I have a dataset with the roles depending on the priorities of each player (some defend better individually, others in zone, etc.). Some players don’t have the ability to defend in certain roles and therefore could only fulfill 2 roles. Therefore, these players would appear as follows:

defenders = {

'Player A': ['A', 'A', 'B'],

'Player B': ['B', 'A', 'B'],

'Player C': ['C', 'A', 'B'],

'Player D': ['B', 'A', 'C'],

'Player E': ['B', 'B', 'A'],

'Player F': ['A', 'A', 'B'],

'Player G': ['A', 'A', 'C'],

'Player H': ['C', 'C', 'A'],

'Player I': ['C', 'C', 'A'],

'Player J': ['C', 'A', 'C'],


On the other hand, I have another dataset with the opponent team, whose players are categorized according to their degree of threat in the corners. Thus, they could have up to 3 threat levels (1 being the most dangerous and 3 the least dangerous). However, each player would only have 2 levels of danger. Thus, a player 1, 1 would be more dangerous than a player 1, 2 and a player 3, 3 is not dangerous at all.

opponents = {

'Opponent Player 1': ['1', '1'],

'Opponent Player 2': ['1', '1'],

'Opponent Player 3': ['3', '2'],

'Opponent Player 4': ['3', '2'],

'Opponent Player 5': ['1', '2'],

'Opponent Player 6': ['1', '2'],

'Opponent Player 7': ['2', '3'],

'Opponent Player 8': ['2', '3'],

'Opponent Player 9': ['2', '2'],

'Opponent Player 10': ['3','3'],


In my end result at least 5 of the most dangerous players would have to be marked individually (in principle, I would like the best A-role defenders to mark the most dangerous attackers). I know that this is a program with a solution similar to what the Gale-Shapley algorithm can offer, but with some modification that I don’t know exactly how to achieve. The end result of this problem would be:

Individual marks:

  • Player A - Opponent Player 1
  • Player F - Opponent Player 2
  • Player G - Opponent Player 5
  • Player C - Opponent Player 6
  • Player J - Opponent Player 9

Zonal marking:

  • Player B
  • Player D
  • Player E

Front of the box:

  • Player H
  • Player I

The idea would also be to be able to enter into the program the substitutions that are being made during the match both in my team and in the opponent team so that the program quickly assigns the markings and roles to my players.

I would appreciate any kind of help because I don’t really know where to start. I read about the ‘stable marriage’ algorithm but as you can see, it’s not the same problem because I don’t intend to match all players. Thanks in advance! :heartpulse: