A371949 Array read by antidiagonals: T(n,k) is the numerator of the probability of attacker victory in the game of Risk when n attacking armies face k defending armies in a territory.
3240, 6415200, 45606240, 12702096000, 170514616320, 430865593920, 25150150080000, 753411576268800, 2398271752673280, 3552119332387200, 49797297158400000, 2595785508222566400, 13369373984761528320, 22330692411407861760, 28155000551019598080
Offset: 1
Examples
This sequence lists the numerators T(n,k) along antidiagonals of the probability of n attacking armies winning against k defending armies. The denominator of each probability is 7776^(n+k-1). The sequence starts with T(1,1) and moves to T(1,2), T(2,1); T(1,3), T(2,2), T(3,1); etc. Hence the first value is 3240/7776 = 5/12. A k-vs.-k attack by 4 or fewer armies, played until complete elimination, will favor the defender, but 5-vs.-5 or more will favor the attacker, with the probability of victory by the attacker steadily increasing with each additional die added to both sides.
Programs
-
Python
from itertools import product from collections import Counter from functools import lru_cache from fractions import Fraction def get_elims(o,d): return tuple(-''.join(['od'[int(o>d)] for o,d in zip(*[sorted(i)[-2:][::-1] for i in [o,d]])]).count(j) for j in 'od') @lru_cache() def elim_p(o_n,d_n): return {j:Fraction(k,7776) for j,k in Counter([get_elims(i[:o_n],i[o_n:o_n+d_n]) for i in product(range(1,7),repeat=5)]).most_common()} @lru_cache() def res_p(o_n,d_n): return {(o_n+i[0],d_n+i[1]):j for i,j in elim_p(min(3,o_n), min(2,d_n)).items()} def get_final_result(o_n,d_n): d,g = {(o_n,d_n):1}, [(o_n,d_n)] while g: w,p = g[0], d.pop(g[0]) for i,j in res_p(*w).items(): d[i] = d.get(i,0)+j*p g = [i for i in d.keys() if min(i)>0] return d def get_win_count(o_n,d_n): return (sum(j for i,j in get_final_result(o_n,d_n).items() if i[0]>i[1])*(7776**(o_n+d_n-1))).numerator a = [get_win_count(o_n,t-o_n) for t in range(2,30) for o_n in range(1,t)]
Comments