Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separable Deal hands? #122

Open
HighDiceRoller opened this issue Jan 7, 2023 · 4 comments
Open

Separable Deal hands? #122

HighDiceRoller opened this issue Jan 7, 2023 · 4 comments

Comments

@HighDiceRoller
Copy link
Owner

HighDiceRoller commented Jan 7, 2023

Count generation process for two hands:

  1. First hand generates counts. These cards must be removed from the deck before the next step.
  2. Second hand generates counts.
  3. All remaining cards of that outcome are removed. Probably entails separating generate from pop.

Questions:

  • How to pass the information that the first hand drew X cards to the second hand?
    • This prevents the use of independent itertools.product.
    • Thread safety? Does this require returning a separate shared state?
  • What is the cache key?
  • What to do with sample?
    • Maybe this should be done on the evaluator side instead?
  • Can binary operators work on two hands drawn from the same deck?
@HighDiceRoller
Copy link
Owner Author

HighDiceRoller commented Jan 7, 2023

Somewhat ambitious idea:

  • Split OutcomeCountGenerator into two objects: a base multiset, and a operation acyclic digraph that pulls counts from that multiset.
  • Deck would be an example of a multiset. We could potentially even consider Pool to be a distribution over multisets and allow to "deal" dice from the result, though the practical use cases for this seem to be limited.

Potential syntax:

a, b = deck.draw(5, 5)  # a, b are considered to be drawn from the same deck
# probably not mandatory to use them all at the same time
# but if we do another draw it's considered to be from a fresh deck
(a & b).sum()  #  a & b creates an intersection puller, which can then be sent to SumEvaluator()

# but what if:
evaluator.evaluate(a & b, a | b)
# how many hands are pulled, two or four?

# also
evaluator.evaluate(d6.pool(6), d6.pool(6))
# are the pools the same or independent?

Puller interface:

  • Which generator(s) to ask for. We need to be able to map between the original generator and the current popped generator.
  • How many draws to ask for from each generator.
  • Given how many hits resulted, what the resulting count is.
  • By the end of next_state we need to generate the following:
    • The generator after pulling + popping the outcome.
    • The tuple of pullers after pulling a particular set of counts.
    • The counts themselves. Exactly one per puller?
    • The weight to assign to this edge.

Evaluation:

  • Determine the set of all parent multisets.
  • Generate counts. Can we do this by considering each puller in turn, or do we first need to determine the total number of pulls from each parent generator?

@HighDiceRoller
Copy link
Owner Author

HighDiceRoller commented Jan 8, 2023

Arguments against:

  • Implementation / maintenance difficulty.
  • May complicate API, result in unintuitive/ambiguous-looking code.
    • I don't know how far I want to go down the variable-probability distribution distinction. Right now we have a decent separation by "freezing" via apply, map, evaluate etc. and treating objects as independent otherwise. It's nice not to have to think about "spooky action at a distance".
  • At some point, it's probably better to just write the evaluator directly.

@HighDiceRoller
Copy link
Owner Author

Decided not to pursue this at this time.

@HighDiceRoller
Copy link
Owner Author

HighDiceRoller commented Jan 31, 2024

Thinking about this again. I don't really like the way Deal occupies multiple slots at the moment, and it makes it hard to do things like

a, b = deck.deal(3, 3)
print((a - b).count())

This would require some way of querying the deal for multiple hands at a time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant