## How do I model the fighter’s Great Weapon Fighting fighting style in Anydice?

I was trying to create an AnyDice function to model the Great Weapon Fighting fighting style (which lets you reroll 1s and 2s), but I couldn’t get it to work on any arbitrary dice.

I’ve found this one:

``function: reroll R:n under N:n {    if R < N { result: d12 } else {result: R} } output [reroll 1d12 under 3] named "greataxe weapon fighting" ``

And it works fine. But I don’t know how to make the function generic so i don’t need to change the d12 every time i want a different dice to reroll.

I’ve tried

``function: reroll R:n under N:n {    if R < N { result: d{1..R} } else {result: R} } output [reroll 1d12 under 3] named "greataxe weapon fighting" ``

but it is not giving the right probabilities. Maybe if I could fetch the die size inside the function…

## How to make Anydice see if two values are the same among 3 dice and keep them?

Is there a way to calculate/simulate rolling 3d20 and spit the middle one (that is easily done with middle function), or if its value is the same as the high or the low one, spit that one too?

## Is it possible to model these probabilities in AnyDice?

I was asked by a pal to help him model a dice mechanic in AnyDice. I must admit I am an absolute neophyte with it, and I offered to solve it using software I’m better versed in. I’d like to be able to help them do this in AnyDice.

The mechanic is as follows:

• The player and their opponent are each assigned a pool of dice. This is done via other mechanics of the game, of which details are not germane. Suffice to say, the player will have some set of dice (say 2D6, 1D8, and 1D12) that will face off against the opponents pool (which will generally be different from the player’s, say 3D6, 2D8 and 1D12).
• The player and their oppoent roll their pools.
• The opponent notes their highest value die. This is the target.
• The player counts the number of their dice that have a higher value than the target, if any.
• The count of the dice exceeding the target, if any, is the number of success points.

I searched the AnyDice tag here for questions that might be similar, the closest I found was "Modelling an opposed dice pool mechanic in AnyDice", specifically the answer by Ilmari Karonen.

That question and answer, however, deals with only a single die type.

Can a question like "What are the probabilities of N successes when rolling 4D6 and 6D20 as the player against 6D6 and 4D20 for the opponent?", be handled in AnyDice and produce a chart similar to that below?

## ANYDICE – Help with a dice pool showing success against a range of target numbers

I’m having a hard time coding an anydice script to show what I want.

Let me contextualize the mechanic I’m trying to simulate:

You roll a POOL of d10 against a TARGET number. If at least one die from the POOL is equal to or higher than the TARGET, the roll is a success. The count of such dice is the degree of success, but that isn’t my focus at the moment.

I’d like to have a graph for the chances of success of various POOLs of different sizes up to 10 (1d10, 2d10, 3d10…10d10) against different TARGETs from 2 to 10 (2, 3, 4… 10).

The caveat is: I’d like the graph to be layed out in such a way that:

• the x axis represents the TARGETs;
• the y axis represents the chances of at least 1 success;
• each line represents a POOL,

so I can see the chances that each POOL has to succeed against a whole range of TARGETs.

Can any anydice wizard help me with this, please?

## My any-dice program times out, when calculating large limit break checks

Someone in chat helped write an anydice program to calculate limit breaks in an RPG I’m developing, but after making some changes, it times out for dicepools > 7.

The system I have in mind, is that if any of the dice you roll is below a threshold, you can bank the sum of all failed rolls for later use, by converting it into a limit break token (currently, at an exchange rate of 1:4). I’m toying with requiring a certain number of successes before you can convert failed, which may or may not be slowing down the program.

``function: sum X:s less than L with at least K successes {   R: 0   S: 0   loop I over X {      if I <= L { R: R + I }      if I > L { S: S + 1 }   }   if S >= K { result: R/4 }   if S < K { result: 0 }  } ``

Is there a more efficient way of running this program? Initially before my tweaks, the same helpful person suggested this as an alternative to the function: `output 3d{1..6, 0:6} named "Alt dice"` but I can’t figure a way of running that, which is probably less likely to time out, and still check for a minimum number of successes.

Here is the code that causes the time out:

``output [sum 1d12 less than 7 with at least 0 successes] named "1 die limit break" output [sum 2d12 less than 7 with at least 1 successes] named "2 die limit break" output [sum 3d12 less than 7 with at least 1 successes] named "3 die limit break" output [sum 4d12 less than 7 with at least 1 successes] named "4 die limit break" output [sum 5d12 less than 7 with at least 1 successes] named "5 die limit break" output [sum 6d12 less than 7 with at least 1 successes] named "6 die limit break" \Times out around here\ output [sum 7d12 less than 7 with at least 1 successes] named "7 die limit break" output [sum 8d12 less than 7 with at least 2 successes] named "7 die limit break" output [sum 9d12 less than 7 with at least 2 successes] named "7 die limit break" output [sum 10d12 less than 7 with at least 2 successes] named "7 die limit break" ``

I found the timeout point by running each line individually.

## AnyDice — efficiency of code calculating rolls hitting a target with mixed pools; hitting the 5 second barrier

I have some code that is hitting the 5 second barrier;

``function: target N:n of A:s B:s C:s {     result: [count {1..N, 1..(N/2)} in [sort {A, B, C}]] } output [target 7 of 4d12 0d20 0d8] output [target 7 of 4d12 2d20 0d8] output [target 7 of 4d12 4d20 0d8] ``

Even if I remove the final output line, it still fails.

I believe the code does what I want it to – calculate the number of dice rolling at or under the target from mixed pools (it runs when using other pools: d20s seem to be a problem).

Is there anyway I can improve it so that at least the first two of these output lines will run (or better yet, all three of them)?

N.b. from my perspective these were some of the simplest pools I wanted to look at.

## Another syntax for Anydice mechanic question

I’m trying to build a function to model not just a roll of the dice, but to have boolean operators to toggle using various powers that effect the dice. I’ve gotten everything to work except for one thing- looking at the result of the roll, seeing if a ‘1’ was rolled and then changing that ‘1’, but only once.

The dice mechanic is for Cryptomancer, and it works by takinging your rank in a skill which is 1 to 5 and rolling that many d10’s plus a number of d6’s that total to 5 dice. For d10s, 1’s are always botches (-1), numbers under the target number are 0’s and numbers equal to or greater the target are successes (+1). On the d6’s 1s are botches, 6s are success and everything else is 0.

I’ve been using custom die for my rolls but set the function up to build the roll off just a skill number and challenge number. Here’s what i got so far-

`function: sb B:n sp P:n skill SKILL:n vs CHALLENGE:n{ if P=1{ ROLL: SKILLd{-1,0:(CHALLENGE-2),1:(10-CHALLENGE),2}+(5-SKILL)d{-1,0:4,1} } else { ROLL: SKILLd{-1,0:(CHALLENGE-2),1:(11-CHALLENGE)}+(5-SKILL)d{-1,0:4,1} } if B=1{ if 5@ROLL=-1{ ROLL:ROLL+2 } } result:ROLL } `

The goal is that you can toggle things by entering a 1 or 0 for the values B and P to turn them on or off. P=1 makes all ’10s’ rolled be worth +2 success instead of +1. B=1 is suppose to check the last value of the roll, and if a -1 is present add 2 to the whole total, there by turning one and only one botch into a success, even if there are multiple botches in the roll.

Everything works till i turn on B. then i get an error that the boolean operation `if` can only be used on numbers. Turns out `5@ROLL` isn’t giving me the lowest roll of 5 dice but the probability of what that roll will be. How do i fix this? How can i convert `ROLL:d` into `ROLL:s`?

## Subtracting opposed dice in Anydice

In some games, opposed dice rolls are subtracted. An example (although this is a boardgame, not an rpg) is Twilight Struggle. Not only is it important to determine who won, but by how much. A similar situation would be when the DM creates a mechanic where opposed skill checks on say d20s are compared (who won by the most). I’m wondering how to do this in anyDice.

What is an easy way of doing this in anyDice?

## How to model opposed rolls in Anydice?

I’ve seen there are quite a lot of brilliant people on this board answering questions about Anydice. I am hoping somebody will be kind enough to answer this one too.

I want to use anydice to figure out the probability of success with opposing dice rolls. For example, 1d6+1d8 (test roll) vs 1d10+1d4 (challenge roll). The challenge roll determines the target number. If the test roll meets or exceeds the challenge roll, the attempt succeeds.

How do I set that up in Anydice?

## How should I emulate the highest in an irregular dice pool in AnyDice?

Basically, I’m trying to do something like [highest 1 of {a pool of Xd4, Yd6, Zd8, etc, all together}]

For example:I roll 1d4 and 1d6 and 1d8; their results are, respectively, 4(out of 4 max), 5(out of 6) and 2(out of 8). My end result is 5 here.

How would I do such a thing in AnyDice syntax?