Open
Conversation
Signed-off-by: Aamooum <younes.aamoum10@gmail.com>
Signed-off-by: Aamooum <younes.aamoum10@gmail.com>
Signed-off-by: Aamooum <younes.aamoum10@gmail.com>
Signed-off-by: Aamooum <younes.aamoum10@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I created a simulation program to test different strategies and find the best way to maximize the number of guests who drink water fairly, even when some guests act selfishly.
abstraction :
This simulation models fair resource sharing among guests with dynamic and unpredictable behavior. Since the requirements do not specify how cups should be divided or whether guests agree to share, we assume all guests mutually agree to divide 2 cups equally among themselves. We also assume cups can be realistically divided among all guests. Under this agreement, the first cup flows left-to-right and the second cup flows right-to-left, allowing each guest to drink twice in ideal conditions. The program simulates guests with two behavioral types: "good" (fair sharers) and "bad" (selfish). Guests can randomly change their mindset during each round, and bad guests can choose to drink all or partially share. Additionally, only bad guests can change seats strategically to maximize their intake. Initial simulations without enforcement showed poor fairness rates (~54% for 7 guests, ~38.5% for 14 guests) due to seat-changing exploitation. To address this, we implemented a collective ban system where all guests act as enforcers (This system prevents a guest from lying or assigning a drink to the wrong person. The cup's water level is visible to everyone, and the guest making an accusation must provide clear proof. If the amount of water left is less than the number of people who have not yet drunk, it will be obvious that someone has cheated, and that person will be banned. Furthermore, the system is designed to account for selfish behavior, making it possible to identify individuals who attempt to drink more than their share.) if any guest drinks more than their agreed share or drinks entire cups, all other guests detect and vote to ban them. This social enforcement mechanism is feasible for smaller groups (N ≤ 14) where all guests can observe violations and communicate. The banned guest is then excluded from drinking. The system reallocates cups from banned guests to non-banned participants, maximizing resource usage. Results improved significantly: with seat changes and collective bans enabled, fairness increased from 54.7% to 58.8% for 7 guests and from 38.5% to 43.0% for 14 guests. However, perfect fairness (100%) remains unattainable due to inherent selfishness. The collective ban system demonstrates that community-based rule enforcement provides a practical balance between fairness and feasibility in shared resource scenarios.It is important to note that there are additional scenarios and loopholes that selfish guests could exploit; however, many more strict rules can be implemented to prevent these behaviors and further improve fairness.
Scenario | 7 Guests | 14 Guests
No ban, no seat changes | 66.3% | 61.9%
No ban, with seat changes | 54.7% | 38.5%
Ban, no seat changes | 67.2% | 61.1%
Ban, with seat changes | 58.8% | 43.0%
So in conclusion, adding strict rules can increase the number of guests who get to drink water. However, since there is always a high probability that some guests will act selfishly and disrupt fairness, the percentage can improve but will never reach 100% — unless every guest remains good and never changes their mindset to become bad.
I created a graph with AI to illustrate this. The repository also contains additional information and the program's source code in the commit .
I am really interested in knowing your opinion on this solution.