Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pairing in a list
#1
I have an assingment which is about a chess tournament that has as many players and turns as you have given as input, and I need to update the ranking list every time according to some criteria (points earned, ELO, Alphabetical sort,etc.). If possible, every player has to change its color and has to be paired with the closest player in the ranking if they've never played before. My problem is updating the ranking algorithm. I have a list and a dict which holds the match records and players statistics but I have no idea about how to match them with the closest one in the ranking according to colors and if they have played before. So as I said I need some ideas for this part of the algortihm. I cannot share my code and I don't want any code, but just some ideas in order to figure out the algorithm. I am just a beginner and Im trying to use only the basic and fundamental things like lists and dictionaries (just standard python library) I would be so happy if you give me a hand in this.Btw the system is called the swiss system and more information can be found at wikipedia. This is my first post and if I made any mistakes please let me know. Additional info: Every player doesn't have to play with eachoter, a player cannot use the same colour 3 in a row and if thw number of players is odd, last player in the ranking gets one point without matching and the player cannot be the last one in the list again)
Reply
#2
We understand "swiss pairing".
But your problem definitiion seems a little cryptic.
What does it mean when you say: " I need to update the ranking list every time "
What happens "every time" ?

Paul
jakemace likes this post
Reply
#3
Oh, sorry. I mean "just before every new turn." My own approach to this problem is updating the list which holds the players and ranking the players every time (with lambda) according to the points they earned and other criteria before the new turn begins BUT my issue is I don't have any idea about checking whether or not the players has played with each other before. This is critical because when a turn ends, I print the results of that turn and I have to update the points, then I update the rankings but I print according to the ranking list. If I cannot arrange the ranking list my printings will be useless. So I rank them at the beginning according to their points but not according to their previous colors or previous opponents. In order to be more clear: my dictionary is like {license number of player: [name, points, ELO, color(at the current round)]} and I also have a match record dictionary which is like {license num: [opponent's license num, color at that round, points earned at that round]} and I append the results of the next round to related key. I get the values from the first dict and rank them but as I said many times, I cannot control two qualities: whether they played before and if the player has the same color as the previous tour. So there are no problems with updating the points or rankings but I need to adjust them according to the rules: not taking the same color 3 times in a row and matching players with similar or same points if possible. I do the pairings by slicing the ranking list by 2. In this way I take 2 players if the player number is odd I control it and don't take the last one. In this step, I also have a list that holds the last player's license number because the same player cannot be idle twice. (another problem is I don't know where to use it and how to use it)Thanks for taking care and asking for details.
Reply
#4
I'm sure there are a zillion ways to do all this.
As you don't want code, an idea to check if players have played each other or not.
Create a list matches = []. Each time a new match is started, you update the list: matches = ['A-B','B-C', ...]
Now it's easy to check if A-B or B-A is already in the list.
If you make the first of the pair the "white" player,
you can check how many times they have started with white using the same list.
You can check how many matches they played etc.
My 2 cts,
Paul
jakemace likes this post
Reply
#5
Thanks for your support. I found a solution and want to discuss that. Now I'm trying to find it.
Reply
#6
During my research, I found this: https://github.com/gnomeby/swiss-system-...pairing.py
If possible, -because I have no idea about classes- can you please explain to me what's going on with that solution(I mean the algorithm he uses and how he manages the change of colors and previous match records). It would be a wonderful resource for me and I can figure out the rest. One more thing is, I tried to use the "matches" list but still didn't understand how to associate it with color. Also, can you please be more specific about "checking"? I mean how can I check my list slices with matches?
Reply
#7
You're asking a bit too much. Wink
When i plan to make an app like, 4-in-a-row, blackjack, Texas hold'm, even swiss pairing,
i know that there are many people who published a solution for that.
I never look at those, because (a), there is no fun in it, (b) by the time you figured out what
somebody else has done, you may have done it yourself.

I will elaborate on my matches idea:
Three players: A, B, C (license numbers as you call them)
A against B, A starts with white : 'A-B', if B starts with white 'B-A'.
You can easily check if 'A against B' has already been played with the "in list" function.(or B-A as well)
You can tell how many times A had white, by counting the number of 'A-x'' in the list.
You can count the number of matches A played. (black + white distinctive)
You can also tell who A did not play.
You can link A directly to your dictionary.
Still in the same list, if you want to show who won, you can do 'a-B', 'B-c' if your licence numbers have a string in them.
Limitless really...
Paul
Reply
#8
Thanks for answering. Getting feedback from experienced people has always been a pleasure for me and what you said was really useful. You’re so right.
Reply
#9
i have the same project could you help me?
buran write Feb-05-2021, 07:59 PM:
Please, don't hi-jack threads. Start your own threads, showing your code and asking specific questions.
Reply
#10
Hi, I got a list like [1,2,3,4,5,6,7,8,9], and each of the values in the list has two specific qualities (let's say the first one is a boolean and the second one is an int). I need to pair them. For the first time, it's easy: I just pick by list slicing. But when it comes to next time, I have to check both if they have paired already in one of the earlier times and if they have the same value of bool. Also, picking the ones that are closest to each other in terms of their int values which I talked about at the beginning. At the end, output will be like [[1,2],[3,4]...] Please do not say just iterate over the list because the problem is I don't know how.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020