Displaying Chip value contribution #6 #20

Closed
Vutukuri15 wants to merge 0 commits from vutukuri15/6 into main
Vutukuri15 commented 2025-02-15 19:58:35 -08:00 (Migrated from github.com)

This PR is still a work in progress.

This PR introduces the ChipDistributionSummary component, which calculates and displays the distribution of poker chips based on the total buy-in amount, number of players, and available chip counts. The component handles the distribution of chips in descending order of chip values (from higher denomination to lower), ensuring that the total value per player matches the buy-in amount.

This PR is still a work in progress. This PR introduces the ChipDistributionSummary component, which calculates and displays the distribution of poker chips based on the total buy-in amount, number of players, and available chip counts. The component handles the distribution of chips in descending order of chip values (from higher denomination to lower), ensuring that the total value per player matches the buy-in amount.
djwesty (Migrated from github.com) reviewed 2025-02-15 19:58:35 -08:00
MantashaNoyela (Migrated from github.com) reviewed 2025-02-15 19:58:35 -08:00
djwesty commented 2025-02-16 16:03:25 -08:00 (Migrated from github.com)

I gave this some thought to try to help with your algorithm. I don't have a solution to present but I can point out a few things with the code that might represent a misunderstanding or otherwise might be roadblock to a working algorithm.

const chipValues = [0.05, 0.25, 1, 2.5, 5]; // Chip values: white, red, green, blue, black

  • This is a problematic starting point, by hard-coding the chipValues. Consider a game with a $5 buy-in as opposed to a $100 buy-in. for the $5 game, you might want [.05, .10, .25, 1, 2.5] as the chip values, and for the $100 game you might want something like [1, 5, 10, 25, 50]. Also we cannot assume 5 unique color chips, that is just the maximum.
  • Determining the chip values needs to be dynamic and an is important part of the algorithm. The idea I have is to hard-code a set or array such as const validDenominations = [0.05, 0.10, 0.25, 0.50, 1, 2, 5, 10, 20, 50, 100];. Your algorithm can then logically pick 5 (or fewer) of these elements as the chip values. They way you pick the values may be tricky. But as a bound the most value chip should be worth no more than half the buy-in. You can add other bounds as they make sense, and add bounds to the buy-in feature as well to help constrain the complexity.

let distribution = [0, 0, 0, 0, 0];

  • as hinted at above, there can be between 1 or 5 unique color chips, so we may want to represent this dynamically instead.

The rest of your algorithm shows thoughtfulness, but depends on the chipValues defined. Since that needs to be done differently, it's likely to effect the rest of the algorithm with some significance.

As a last thought, I worded this question as best I could to ChatGPT. The algorithm outline it suggested describes a greedy approach which looks promising. I think that is closer to what will work for us, but cannot say if it is fully technically correct or not. I wouldn't pay too much attention to the code since the variable names and data-structures may be different.

notes to ease complexity. These are optional:

  • for 4-5 unique color chips, we can contrain the highest value chip to be half buy-in amount
  • for 2-3 unique color chips, we can constrain the highest value chip to be 1/4 buy-in amount
  • We can restrict/disallow one color chip games.
  • We can play limits on the buy-in amount to prevent unusual values, make them multiples of $5, etc.
  • We can add any other contraints to the inputs to limit complexity
  • We can use a "guess and check" approach if it helps. Pick some denominations (possibly with some randomness if it makes sense) and see if we can build a distribution that totals back up to the buy-in amount. If it fails, we can pick different denominations from the set and try again
I gave this some thought to try to help with your algorithm. I don't have a solution to present but I can point out a few things with the code that might represent a misunderstanding or otherwise might be roadblock to a working algorithm. `const chipValues = [0.05, 0.25, 1, 2.5, 5]; // Chip values: white, red, green, blue, black` - This is a problematic starting point, by hard-coding the chipValues. Consider a game with a $5 buy-in as opposed to a $100 buy-in. for the $5 game, you might want `[.05, .10, .25, 1, 2.5]` as the chip values, and for the $100 game you might want something like `[1, 5, 10, 25, 50]`. Also we cannot assume 5 unique color chips, that is just the maximum. - Determining the chip values needs to be dynamic and an is important part of the algorithm. The idea I have is to hard-code a set or array such as `const validDenominations = [0.05, 0.10, 0.25, 0.50, 1, 2, 5, 10, 20, 50, 100];`. Your algorithm can then logically pick 5 (or fewer) of these elements as the chip values. They way you pick the values may be tricky. But as a bound the most value chip should be worth no more than half the buy-in. You can add other bounds as they make sense, and add bounds to the buy-in feature as well to help constrain the complexity. `let distribution = [0, 0, 0, 0, 0];` - as hinted at above, there can be between 1 or 5 unique color chips, so we may want to represent this dynamically instead. The rest of your algorithm shows thoughtfulness, but depends on the `chipValues` defined. Since that needs to be done differently, it's likely to effect the rest of the algorithm with some significance. As a last thought, I worded this question as best I could to [ChatGPT](https://chatgpt.com/share/67b27af2-c56c-8004-a2a1-b0a863ca8c12). The algorithm outline it suggested describes a greedy approach which looks promising. I think that is closer to what will work for us, but cannot say if it is fully technically correct or not. I wouldn't pay too much attention to the code since the variable names and data-structures may be different. notes to ease complexity. These are optional: - for 4-5 unique color chips, we can contrain the highest value chip to be half buy-in amount - for 2-3 unique color chips, we can constrain the highest value chip to be 1/4 buy-in amount - We can restrict/disallow one color chip games. - We can play limits on the buy-in amount to prevent unusual values, make them multiples of $5, etc. - We can add any other contraints to the inputs to limit complexity - We can use a "guess and check" approach if it helps. Pick some denominations (possibly with some randomness if it makes sense) and see if we can build a distribution that totals back up to the buy-in amount. If it fails, we can pick different denominations from the set and try again
djwesty commented 2025-02-23 23:33:44 -08:00 (Migrated from github.com)

Closing for new PR to change authorship

Closing for new PR to change authorship

Pull request closed

Sign in to join this conversation.
No description provided.