Skip to content

Variable target numbers #181

Answered by HighDiceRoller
jllancaster asked this question in Q&A
Discussion options

You must be logged in to vote

Happy to get your message! In this case it's easiest to use the @map_function decorator, which runs a function over all outcomes of dice and all tuples-of-outcomes of pools.

from icepool import d6, map_function

@map_function
def var_target(pool, target):
    target = max(target, 2)
    return sum(x >= target for x in pool) + pool.count(6)

output(var_target(d6.pool(6), d6.highest(2, 1)))

You can try this in your browser here.

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@jllancaster
Comment options

@HighDiceRoller
Comment options

@jllancaster
Comment options

@HighDiceRoller
Comment options

@jllancaster
Comment options

Answer selected by jllancaster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants