This is a tool for calculating dice probabilities and outcomes for X-Wing Miniatures by Fantasy Flight Games. The goal of the tool is to aid players in list building, target selection and token spending by helping to develop intuition about the probabilities of various outcomes.
Computing simple dice probabilities by hand is straightforward, but more complex scenarios involving many tokens and multiple attacks become tedious and error-prone even when using a spreadsheet.
Rather than rely on random simulation, this tool calculates probabilities directly via an exhaustive search of all possible outcomes. This runs extremely fast (a couple milliseconds for most realistic cases) and produces accurate and repeatable results.
Source code for the tool is available on Github under the MIT license. Please feel free to browse the code, fork and/or submit issues and pull requests!
Frequently Asked Questions
- How can I link or bookmark a specific result?
How can I see the numbers?
One a result is simulated, simply hover over (or tap) any bar in the charts to see the probabilities.
Alternatively, some of the forms additionally output a data table which makes it easy to copy the results into an external spreadsheet.
Which effects and triggers are active?
In general, any effect that you enable is considered to be "active". Any conditions outside of tokens (such as being in arc or at a given range) are assumed to be satisfied if you enable the effect.
Since tokens can change over the course of an attack (particularly in multi-attack situations), effects do respect conditions related to tokens. For instance, Juke will only be active if the owner has an evade token.
If a weapon or effect requires spending tokens to enable the attack (for instance, many munitions require the attacker to discard a target lock to fire) do not include those tokens in the simulation. The simulation effectively begins right before the attacker's initial dice roll, so that is the point in which you should set the token state.
What strategies do the attacker and defender employ?
The attacker tries to maximize the number of hits/crits. It will opportunistically prefer crits, but will not greedily "crit chase" by trying to reroll hits into crits.
The defender tries to minimize or entirely avoid taking hits. In cases where there are token spending choices, the defender will prefer to keep tokens that are more useful on defense in case there is a second attack. For instance, if a defender can spend either a focus or evade to fully evade an attack, it will normally prefer to spend the focus and hang onto the evade. While the "optimal" choice depends on additional factors (dice, mods and tokens available to each player), this heuristic works well for the typical situations encountered in X-Wing.
Can you add [some upgrade] to the calculator?
Anything can be added given the proper time and resources. Generally things that aren't yet implemented fall into a couple of categories.
- Things with too many UI complexities or too much context (example: health/shields of the ships involved).
- Things with unclear rules interactions. This includes cases where card combinations aren't possible in X-Wing today (due to lacking specific upgrade slot combinations or faction limitations), or cases that are possible but rarely used and thus have never received needed clarification in the FAQ.
- Rarely used upgrades, particularly in combination with another one of the downsides.
If you want a specific upgrade prioritized, please feel free to upvote or file an issue on Github
1.0 Calculator FAQ
What's the difference between "Basic" and "Advanced" calculators?
Both the basic and advanced calculators use the same underlying simulation. The only difference is in how the simulation parameters are presented in the user interface.
The basic form uses card and ability names directly from the game, so it should be intuitive for most people. The attackers and defenders tokens and upgrade cards are grouped in two separate sections. While it's possible to test out illegal card combinations (the form does nothing to prevent this), you are generally limited to the effects present on the available cards. A few concessions are made for clarity; for instance, the type of attack (single, multiple) is set directly rather than implicitly via upgrade cards (gunner, etc).
The advanced form is a more direct interface to the parameters of the simulation. It can express a superset of the basic form, including a wide variety of options that are not currently possible in the game. Simulation parameters are organized according to where they occur in the timing chart. A few "special effects" still reference card names when it is more concise to do so versus spelling out the underlying effect.
What's the "Multiple Attacks" calculator for?
The multiple attacks or "alpha strike" form also uses the same underlying simulation, but it is organized to model several different attackers all attacking the same defender in sequence. This is useful for determining the probability of a ship being destroyed by an alpha strike before getting to fire, among other things.
The options on the alpha form are somewhat more limited due to UI space/complexity considerations, but most of the common attacks can be modeled using a combination of the options in the dropdown menu together with the available tokens and effect toggles.
Do the attacker and defender play optimally in the 1.0 calculators?
The short answer: in most realistic cases, yes. The longer answer: it depends how you define "optimally".
In most common situations it is possible for the attacker to simultaneously optimize for many different metrics: the maximum expected hits, the minimum probability of missing, and so on. Similarly the defender can avoid or minimize expected damage while spending as few tokens as possible.
- Complex Reasonsing: It is possible to construct situations wherein theoretically "optimal" token spending is very complicated. Recall that the goal of the tool is primarily to give players intuition about various realistic outcomes. While a computer can easily compute all possible outcomes before making decisions, it is not reasonable for a human to efficiently search a possibility space consisting of hundreds or thousands of outcomes before making each decision. Thus for the sake of predictability the tool employs heuristics that are reasonable for a human to emulate.
- Risky Decisions: For instance, if Sunny Boundary with a target lock rolls hit/crit, rerolling the crit in an attempt to get a second hit and trigger her ability increases the likelihood of three hits, but also increases the likelihood of falling back to a single hit. In general players only take additional risks in exceptional circumstances, so the tool also favors safe decisions.
- Rerolling: The tool treats the ability to reroll dice in aggregate; for instance, one upgrade that allows rerolling two dice is treated identically to two separate upgrades each granting a single reroll. This is done primarily for user interface simplicity, but it also increases the efficiency of the computation. In most cases this makes no difference but there are edge cases in which it is slightly better to reroll one set of dice first, then depending on the results decide whether to reroll others.
- One Damage on Hit: Currently the attacker's logic is not fully optimal when using "one damage on hit" weapons with multiple attacks, such as twin laser turrets. This occurs in cases where no token spending is necessary because it would be impossible for the defender to evade. This logic will be improved in the future.
How does C-3P0 work?
If there are any hits or crits, the defender will "guess" with C-3P0 the number of evades indicated. As this is a once per turn ability, this can only happen once in multi-attack sequences.
No attempt is made to deduce optimal values to guess as that normally requires additional context from the game state. It's generally more useful to just try different guesses in various situations and observe the results.
How does Palpatine work?
If there are any dice rolled (on attack) or any hits or crits to cancel (on defense), Palpatine will be used. Palpatine happens right after dice are rolled, before the opponent modifies them. The die that is modified by Palpatine cannot be modified further as per the game rules.
Simple logic based on the passive mods available determines which die to change. No attempt is made to do complex reasoning about potential outcomes of rerolling dice, etc.
How does Crack Shot work?
The logic for the attacker is simple: if crack shot can be used to push extra damage through, it will always be used. If it's not necessary due to the defender having extra evades or effects like "One Damage on Hit", it will not. If Crack Shot is ever used, it will show up in the Expected Token Delta chart.
The presence of Crack Shot also changes defender token spending logic: the defender will attempt to have an extra evade result available, even if that means spending tokens to that end.
In the presence of "One Damage on Hit" the defender will usually not spend anything if it can't entirely avoid the attack. If Crack Shot is present, it will still spend tokens if it can match the uncancelled hits, since even if the attacker then uses Crack Shot to push the one damage through, that is a valuable outcome as it removes Crack Shot from any follow-up attacks.