I tried coding this one as an exercize in haskell, but then I remembered that haskell is completely unreasonable to use when you need to work with numbers, and I resolved to never touch haskell again.
That being said, the pattern matching in haskell is SUPER nice for coding setups, you literally just write out one endgame per line and everything Just Works (TM). Shame about the fromIntegral nonsense.
I will have to think about how to do this one, as it's not clear when the game "ends." There's also a ton of abilities, so I'm not sure if random usage of them will really capture the setup well. But I can give it a shot this weekend.
Well, typically I use python too, but I use it to calculate the expected value to an exact number, not by approximation. Which can be done very easily using recursive DP + memoization for simple setups without a ton of roles. Every new role or faction adds an extra dimension of complexity to the space you need to enumerate over.
This is a fun one, I will make a plot. 31-2 is only ~60% town win according to the EV project, which is surprising at first but also makes sense. 98-2 mountainous viable?
The numbers may be hard to see depending on your theme, if so you may need to download the figure. The x axis is the number of town players and the y axis is town win %
I'm sure there is some smart person like implosion or Ircher who knows or could figure out the exact formula. This is the relationship you'd expect though because at very high numbers of townies adding a single townie doesn't really do much to change the odds of hitting scum. Compared to lower numbers where obviously there is a big difference between 7:2 and 9:2.
This is already a solved problem. Town winrate always goes to infinity in mountainous as number of townies approaches infinity. There is no known closed form solution, only a recursive function. In order to balance mountainous, the number of townies is bounded quadratically in proportion to the number of mafia.
The approximation I found is: T ~= 4.08766637 S^2 + 1.318112 S - 0.9068
Then round T to the nearest integer such that T + S is odd.
Somewhere on Google scholar, someone mathematically proved a more interesting result that holds for things like nightess, double day, etc, but I can't find it right now.
It's worth noting that these papers have one dumb assumption that does not affect asymptotic behavior: namely that EV(1 town, 1 mafia) = 0.5, because "when there is a tie in votes you kill randomly" (mathematicians seem to want to skirt around the concept of NLing because they need the game to terminate). And for some examples that we all know and love that are known to satisfy that equality are mountainous (d/r = 1/2 -> mafia proportional to square root of town), nightless: (d/r = 1/1 -> mafia is linear to town, see nightless expectation rule), double day: (d/r = 2/3 -> .. etc... )