Mon Jun 11 18:19:17 2018 by Lightcastle |

Hi, I'm trying to figure out the probabilities for a die system where the object is to match dice with your opponent. Say the obstacle rolls 2d6, and the player rolls 3d6. If the obstacle rolls 3,4, then the player will get a success on matching 3 or 4. It's not going to quite be the same as rolling doubles, and I'm trying to get a sense of how it plays out with different numbers. (Probably will stick to d6, though.) Any idea how one might go about that? |

Tue Jun 12 14:28:34 2018 by Torben |

I'm not entirely clear on what happens if one side or both rolls doubles: If, say, the obstacle rolls 3,4 and the player rolls 3,3,5, is that one success or two? I.e., do you count the number of obstacle dice that you match, or the number of dice that match any obstacle dice? Similarly, if the obstacle rolls 3,3 and you roll 3,4,5, is that one or two successes? What if you roll 3,3,3? Is that one, two or three successes. Could you clarify? |

Tue Jun 12 17:59:46 2018 by Lightcastle |

For now, I'd say that would be 1. While I do intend to eventually consider how I might handle doubles and such, for the moment I am trying to straight up look at a single match of yes or no. So if anything matches, that's 1 success, and that's all I need for the moment. |

Tue Jun 12 18:35:25 2018 by Torben |

What about the case where the obstacle rolls 3,3? Can the player get only one success, or can she get two successes by rolling two 3s? |

Thu Jun 14 10:37:46 2018 by Torben |

O.K., let's start with the simple case: The player gets 1 success for every unique die that matches at least one die in the roll of the obstacle. This means that if the player and obstacle both roll 3,3, the player gets only one success. You can do this this way: `player := different (3d6);` Explanation: `different` discards doubles, so there is only one of each value. `(player keep obstacle)` retains only those values in `player` that are also found in `obstacle` .If you want to count how many pairs of identical dice you can get by picking one die from player and one from obstacle (so player = 3,3, obstacle = 3,3 gives 2 and player = 3,3, obstacle = 3 gives 1), you can do it this way: `player := 3d6;` Explanation: `(player -- obstacle)` removes dice from `player` that are also found in `obstacle` , doing this as a multiset subtraction, so `{3,3} -- {3,4}` is `{3}` and `{3,3} -- {3,3}` is `{}` . We want to count how many dice are removed from `player` (by also being in `obstacle` ), so we count how many there are before removal and subtract the number that is left after removal.Another way to write the last line is `count (player -- (player -- obstacle))` , since this retains exactly those elements of `player` that are also found in `obstacle` . |

Sat Jun 16 19:41:31 2018 by lightcastle |

Thanks so much! I'll poke around with this and see what it spins out to. (I think I grasp the coding logic as well, thanks for laying that out as well.) |