discount, p = [1., 1.], 1. - 29. / 61.
for dist in range(1, 7):
discount.append(discount[-1] * p)
discount += discount[-2:-8:-1]
res, cnt = 0., 0
for king in range(64):
for rook1 in range(64):
for rook2 in range(64):
if king == rook1 or king == rook2 or rook1 == rook2:
continue
cnt += 1
kingx, kingy = divmod(king, 8)
rook1x, rook1y = divmod(rook1, 8)
rook2x, rook2y = divmod(rook2, 8)
attac1hor = 1. if kingy == rook1y else 0.
attac1ver = 1. if kingx == rook1x else 0.
attac2hor = 1. if kingy == rook2y else 0.
attac2ver = 1. if kingx == rook2x else 0.
if kingx == rook1x == rook2x:
if kingy < rook1y < rook2y or kingy > rook1y > rook2y:
attac2ver = 0.
elif kingy < rook2y < rook1y or kingy > rook2y > rook1y:
attac1ver = 0.
elif kingy == rook1y == rook2y:
if kingx < rook1x < rook2x or kingx > rook1x > rook2x:
attac2hor = 0.
elif kingx < rook2x < rook1x or kingx > rook2x > rook1x:
attac1hor = 0.
attac1 = attac1hor * discount[kingx - rook1x] + attac1ver * discount[kingy - rook1y]
attac2 = attac2hor * discount[kingx - rook2x] + attac2ver * discount[kingy - rook2y]
res += attac1 + attac2 - attac1 * attac2
print(res / cnt * 2.)
итого
0.3756044599826443