Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pairing in a list
#11
Could you give a more concrete example? You've talked about bools and ints as an idea, but then your list is all ints, so I'm not sure how this ties together.
jakemace likes this post
Reply
#12
Of course. This is all about a swiss pairing system in a chess tournament. I have a dictionary that holds these "values". (like this: dict={1:[True,3], 2:[False,3]...} The idea is bool value is for if the player has got a BYE before, and the number is the points earned. I'm going to pair all the players according to this criterion and I also have a list (or a pair value) that holds a unique number (or the opponent's number) to measure if these two have played together. One more important thing is this pairing thing will happen x times more(depending on turns). To point out my issue, I thought about iterating over the players list and looking for an opponent but I really don't know how to pick paired guys out to another list and continue without them, at the same time picking the guys which have the closest points.
quick edit: I already sorted the players according to their groups and also made a dict that has keys = points and by this way, I have point groups. I thought it would be great to group players with the same points but still, I have no clue about matching them.
Reply
#13
Have you considered using a module or something that is a little bit more focused on handling data structures? Such as pandas or something similar. I think it would be a lot easier to 'query' on your data based on specific conditions that way.

Ofcourse, it would be possible to write all the logic by yourself. But do you have a proper design to do so? I think you'll soon find out that it is more complex than it seems now.

[EDIT] It's also a good idea to share the code you already have.
jakemace likes this post
Reply
#14
1. How is this different from your other thread? I merge both threads
2. You keep saying - I don't know how. Maybe you need to consult your learning materials or find a tutorial
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#15
(Feb-05-2021, 07:57 PM)buran Wrote: 1. How is this different from your other thread? I merge both threads
2. You keep saying - I don't know how. Maybe you need to consult your learning materials or find a tutorial

One is about the algorithm of swiss pairing. The second is about pairing values in a list according to their criterion. After request, I gave the example as swiss pairing. If you know good learning materials for my topic, why don't you share. And If I knew, why would I open a thread? Just delete the thread if you like.
Reply
#16
(Feb-05-2021, 07:52 PM)Jeff900 Wrote: Have you considered using a module or something that is a little bit more focused on handling data structures? Such as pandas or something similar. I think it would be a lot easier to 'query' on your data based on specific conditions that way.

Ofcourse, it would be possible to write all the logic by yourself. But do you have a proper design to do so? I think you'll soon find out that it is more complex than it seems now.

[EDIT] It's also a good idea to share the code you already have.

Thanks for advice Jeff. I'm just a beginner and trying to use the fundamentals to figure out the solutions for problems like that. As you said, I lost my way between lots of lists and dictionaries Smile I was about to share my code but I found out that my logic is completely wrong when it comes to matching players. Anyways, I'll try to do better according to advices you guys gave, thanks a lot.
Jeff900 likes this post
Reply
#17
(Feb-05-2021, 08:08 PM)jakemace Wrote:
(Feb-05-2021, 07:52 PM)Jeff900 Wrote: Have you considered using a module or something that is a little bit more focused on handling data structures? Such as pandas or something similar. I think it would be a lot easier to 'query' on your data based on specific conditions that way.

Ofcourse, it would be possible to write all the logic by yourself. But do you have a proper design to do so? I think you'll soon find out that it is more complex than it seems now.

[EDIT] It's also a good idea to share the code you already have.

Thanks for advice Jeff. I'm just a beginner and trying to use the fundamentals to figure out the solutions for problems like that. As you said, I lost my way between lots of lists and dictionaries Smile I was about to share my code but I found out that my logic is completely wrong when it comes to matching players. Anyways, I'll try to do better according to advices you guys gave, thanks a lot.

If you ask me, it is always a good thing to keep close to the fundamentals! It makes you understand how things works much better. And besides, using modules like pandas gives alot of overhead. So using such modules is not necessarily the best idea.
jakemace likes this post
Reply
#18
I don't think I fully understand what this "list" looks like,
but when it comes to pairing, why don't you try combinations or variations.
You can make a list with all possible pairings and go from there.
If you import itertools, this is a piece of cake.
Paul
jakemace likes this post
Reply


Forum Jump:

User Panel Messages

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