| For the benefit of RISK players, here's my Ada program and a summary of
its conclusion...
CONCLUSION:
If the aggressor's die total 11 or less throw 3 die else throw 1.
This strategy kills 2.14 aggressors per defender.
/Bevin
with TEXT_IO;
package INTEGER_IO is new TEXT_IO.INTEGER_IO(INTEGER);
with TEXT_IO;
package FLOAT_IO is new TEXT_IO.FLOAT_IO(FLOAT);
package RISK_PACK is
DUMP_EACH_CASE : BOOLEAN := true;
DUMP_BEST_MOVE : BOOLEAN := true;
subtype DIE is INTEGER range 1..6;
subtype CNT is INTEGER range 1..3;
type THROW is array(CNT) of DIE;
procedure XCHG(L,R : in out DIE);
procedure SORT(X : in out THROW);
function "/"(L,R : INTEGER) return FLOAT;
end;
package body RISK_PACK is
procedure XCHG(L,R : in out DIE) is
T : INTEGER;
begin
if L < R then
T := L;
L := R;
R := T;
end if;
end;
procedure SORT(X : in out THROW) is
begin
XCHG(X(2), X(3));
XCHG(X(1), X(2));
XCHG(X(2), X(3));
end;
function "/"(L,R : INTEGER) return FLOAT is
begin
return FLOAT(L)/FLOAT(R);
end;
begin
DUMP_EACH_CASE := false;
DUMP_BEST_MOVE := true;
end;
with TEXT_IO; with INTEGER_IO; with FLOAT_IO; with RISK_PACK;
use TEXT_IO; use INTEGER_IO; use FLOAT_IO; use RISK_PACK;
procedure RISK is
A_D, D_D, A2_D, D2_D : INTEGER;
A_DEATHS, D_DEATHS : array(DIE,DIE,DIE,CNT) of INTEGER;
procedure COMPUTE_TABLE is separate;
procedure CUTOFF_LOOP is separate;
begin
COMPUTE_TABLE;
CUTOFF_LOOP;
end;
separate(RISK)
procedure COMPUTE_TABLE is
AS, DS : THROW;
begin
-- Throw the attacking die
A_DEATHS := (others=>(others=>(others=>(others=>0))));
D_DEATHS := (others=>(others=>(others=>(others=>0))));
for A1 in reverse DIE loop
for A2 in reverse DIE loop
for A3 in reverse DIE loop
AS := (A1, A2, A3);
SORT(AS);
-- Throw the defending die
for D1 in DIE loop
for D2 in DIE loop
for D3 in DIE loop
-- Compute the casualties
for C in CNT loop
DS := (D1, D2, D3);
case C is
when 1 => null;
when 2 => XCHG(DS(1), DS(2));
when 3 => SORT(DS);
end case;
A_D := 0;
D_D := 0;
for I in CNT range 1..C loop
if AS(I) <= DS(I) then
A_D := A_D + 1;
else
D_D := D_D + 1;
end if;
end loop;
A_DEATHS(A1,A2,A3,C) := A_DEATHS(A1,A2,A3,C) + A_D;
D_DEATHS(A1,A2,A3,C) := D_DEATHS(A1,A2,A3,C) + D_D;
if DUMP_EACH_CASE then
PUT(C, width=>1);
PUT(" : ");
for I in CNT range 1..C loop
PUT(AS(I), width=> 1);
end loop;
PUT(":");
for I in CNT range 1..C loop
PUT(DS(I), width=>1);
end loop;
PUT(" => ");
PUT(A_D, width=>1);
PUT(':');
PUT(D_D, width=>1);
NEW_LINE;
end if;
end loop;
end loop;
end loop;
end loop;
if DUMP_BEST_MOVE then
declare
C : CNT := 3;
RATIO : FLOAT := 1000000.0;
begin
if D_DEATHS(A1,A2,A3,3) /= 0 then
RATIO := A_DEATHS(A1,A2,A3,C) / D_DEATHS(A1,A2,A3,C);
end if;
if RATIO < 1.2 then
C := 1;
RATIO := 1000000.0;
if D_DEATHS(A1,A2,A3,3) /= 0 then
RATIO := A_DEATHS(A1,A2,A3,C) / D_DEATHS(A1,A2,A3,C);
end if;
end if;
if (A1>=A2) and (A2>=A3) then
PUT(A1, width=>2);
PUT(A2, width=>2);
PUT(A3, width=>2);
PUT(": throw ");
PUT(C, width=>1);
PUT(" expect ");
PUT(A_DEATHS(A1,A2,A3,C)/216, fore=>2, aft=>2, exp=>2);
PUT(" for ");
PUT(D_DEATHS(A1,A2,A3,C)/216, fore=>2, aft=>2, exp=>2);
PUT(" defenders ");
PUT("ratio = ");
PUT(RATIO, fore=>2, aft=>2, exp=>2);
NEW_LINE;
end if;
end;
end if;
end loop;
end loop;
end loop;
end;
separate(RISK)
procedure CUTOFF_LOOP is
CUTOFF : FLOAT := 0.90;
begin
loop
declare
RATIO, RATIO_2 : FLOAT;
begin
A_D := 0;
D_D := 0;
A2_D := 0;
D2_D := 0;
for A1 in DIE loop
for A2 in DIE loop
for A3 in DIE loop
RATIO := 1000000.0;
if D_DEATHS(A1,A2,A3,3) /= 0 then
RATIO := A_DEATHS(A1,A2,A3,3) / D_DEATHS(A1,A2,A3,3);
end if;
if RATIO < CUTOFF then
A_D := A_D + A_DEATHS(A1,A2,A3,1);
D_D := D_D + D_DEATHS(A1,A2,A3,1);
A2_D := A2_D + A_DEATHS(A1,A2,A3,2);
D2_D := D2_D + D_DEATHS(A1,A2,A3,2);
else
A_D := A_D + A_DEATHS(A1,A2,A3,3);
D_D := D_D + D_DEATHS(A1,A2,A3,3);
A2_D := A2_D + A_DEATHS(A1,A2,A3,3);
D2_D := D2_D + D_DEATHS(A1,A2,A3,3);
end if;
end loop;
end loop;
end loop;
RATIO := A_D / D_D;
PUT(" cutoff = ");
PUT(CUTOFF, fore=>2, aft=>2, exp=>2);
PUT(" ratio = ");
PUT(RATIO, fore=>2, aft=>2, exp=>2);
PUT(" ratio_2 = ");
PUT(A2_D/D2_D, fore=>2, aft=>2, exp=>2);
NEW_LINE;
end;
CUTOFF := CUTOFF + 0.05;
exit when CUTOFF > 2.0;
end loop;
end;
6 6 6: throw 1 expect 1.67E-1 for 8.33E-1 defenders ratio = 2.00E-1
6 6 5: throw 1 expect 1.67E-1 for 8.33E-1 defenders ratio = 2.00E-1
6 6 4: throw 1 expect 1.67E-1 for 8.33E-1 defenders ratio = 2.00E-1
6 6 3: throw 1 expect 1.67E-1 for 8.33E-1 defenders ratio = 2.00E-1
6 6 2: throw 1 expect 1.67E-1 for 8.33E-1 defenders ratio = 2.00E-1
6 6 1: throw 1 expect 1.67E-1 for 8.33E-1 defenders ratio = 2.00E-1
6 5 5: throw 1 expect 1.67E-1 for 8.33E-1 defenders ratio = 2.00E-1
6 5 4: throw 1 expect 1.67E-1 for 8.33E-1 defenders ratio = 2.00E-1
6 5 3: throw 1 expect 1.67E-1 for 8.33E-1 defenders ratio = 2.00E-1
6 5 2: throw 1 expect 1.67E-1 for 8.33E-1 defenders ratio = 2.00E-1
6 5 1: throw 3 expect 1.68E+0 for 1.32E+0 defenders ratio = 1.27E+0
6 4 4: throw 1 expect 1.67E-1 for 8.33E-1 defenders ratio = 2.00E-1
6 4 3: throw 1 expect 1.67E-1 for 8.33E-1 defenders ratio = 2.00E-1
6 4 2: throw 1 expect 1.67E-1 for 8.33E-1 defenders ratio = 2.00E-1
6 4 1: throw 3 expect 1.92E+0 for 1.08E+0 defenders ratio = 1.78E+0
6 3 3: throw 1 expect 1.67E-1 for 8.33E-1 defenders ratio = 2.00E-1
6 3 2: throw 3 expect 1.74E+0 for 1.26E+0 defenders ratio = 1.38E+0
6 3 1: throw 3 expect 2.16E+0 for 8.38E-1 defenders ratio = 2.58E+0
6 2 2: throw 3 expect 1.93E+0 for 1.07E+0 defenders ratio = 1.79E+0
6 2 1: throw 3 expect 2.35E+0 for 6.53E-1 defenders ratio = 3.60E+0
6 1 1: throw 3 expect 2.42E+0 for 5.79E-1 defenders ratio = 4.18E+0
5 5 5: throw 1 expect 3.33E-1 for 6.67E-1 defenders ratio = 5.00E-1
5 5 4: throw 1 expect 3.33E-1 for 6.67E-1 defenders ratio = 5.00E-1
5 5 3: throw 1 expect 3.33E-1 for 6.67E-1 defenders ratio = 5.00E-1
5 5 2: throw 1 expect 3.33E-1 for 6.67E-1 defenders ratio = 5.00E-1
5 5 1: throw 3 expect 1.96E+0 for 1.04E+0 defenders ratio = 1.89E+0
5 4 4: throw 1 expect 3.33E-1 for 6.67E-1 defenders ratio = 5.00E-1
5 4 3: throw 1 expect 3.33E-1 for 6.67E-1 defenders ratio = 5.00E-1
5 4 2: throw 3 expect 1.78E+0 for 1.22E+0 defenders ratio = 1.46E+0
5 4 1: throw 3 expect 2.20E+0 for 7.96E-1 defenders ratio = 2.77E+0
5 3 3: throw 3 expect 1.74E+0 for 1.26E+0 defenders ratio = 1.38E+0
5 3 2: throw 3 expect 2.02E+0 for 9.77E-1 defenders ratio = 2.07E+0
5 3 1: throw 3 expect 2.44E+0 for 5.56E-1 defenders ratio = 4.40E+0
5 2 2: throw 3 expect 2.21E+0 for 7.92E-1 defenders ratio = 2.79E+0
5 2 1: throw 3 expect 2.63E+0 for 3.70E-1 defenders ratio = 7.10E+0
5 1 1: throw 3 expect 2.70E+0 for 2.96E-1 defenders ratio = 9.13E+0
4 4 4: throw 1 expect 5.00E-1 for 5.00E-1 defenders ratio = 1.00E+0
4 4 3: throw 3 expect 1.67E+0 for 1.33E+0 defenders ratio = 1.26E+0
4 4 2: throw 3 expect 1.95E+0 for 1.05E+0 defenders ratio = 1.87E+0
4 4 1: throw 3 expect 2.38E+0 for 6.25E-1 defenders ratio = 3.80E+0
4 3 3: throw 3 expect 1.91E+0 for 1.09E+0 defenders ratio = 1.76E+0
4 3 2: throw 3 expect 2.19E+0 for 8.06E-1 defenders ratio = 2.72E+0
4 3 1: throw 3 expect 2.62E+0 for 3.84E-1 defenders ratio = 6.81E+0
4 2 2: throw 3 expect 2.38E+0 for 6.20E-1 defenders ratio = 3.84E+0
4 2 1: throw 3 expect 2.80E+0 for 1.99E-1 defenders ratio = 1.41E+1
4 1 1: throw 3 expect 2.88E+0 for 1.25E-1 defenders ratio = 2.30E+1
3 3 3: throw 3 expect 2.00E+0 for 1.00E+0 defenders ratio = 2.00E+0
3 3 2: throw 3 expect 2.28E+0 for 7.18E-1 defenders ratio = 3.18E+0
3 3 1: throw 3 expect 2.70E+0 for 2.96E-1 defenders ratio = 9.13E+0
3 2 2: throw 3 expect 2.47E+0 for 5.32E-1 defenders ratio = 4.63E+0
3 2 1: throw 3 expect 2.89E+0 for 1.11E-1 defenders ratio = 2.60E+1
3 1 1: throw 3 expect 2.96E+0 for 3.70E-2 defenders ratio = 8.00E+1
2 2 2: throw 3 expect 2.50E+0 for 5.00E-1 defenders ratio = 5.00E+0
2 2 1: throw 3 expect 2.92E+0 for 7.87E-2 defenders ratio = 3.71E+1
2 1 1: throw 3 expect 3.00E+0 for 4.63E-3 defenders ratio = 6.47E+2
1 1 1: throw 3 expect 3.00E+0 for 0.00E+0 defenders ratio = 1.00E+6
cutoff = 9.00E-1 ratio = 2.10E+0 ratio_2 = 1.79E+0
cutoff = 9.50E-1 ratio = 2.10E+0 ratio_2 = 1.79E+0
cutoff = 1.00E+0 ratio = 2.10E+0 ratio_2 = 1.77E+0
cutoff = 1.05E+0 ratio = 2.13E+0 ratio_2 = 1.74E+0
cutoff = 1.10E+0 ratio = 2.14E+0 ratio_2 = 1.73E+0
cutoff = 1.15E+0 ratio = 2.14E+0 ratio_2 = 1.73E+0
cutoff = 1.20E+0 ratio = 2.14E+0 ratio_2 = 1.73E+0
cutoff = 1.25E+0 ratio = 2.14E+0 ratio_2 = 1.73E+0
cutoff = 1.30E+0 ratio = 2.14E+0 ratio_2 = 1.68E+0
cutoff = 1.35E+0 ratio = 2.14E+0 ratio_2 = 1.68E+0
cutoff = 1.40E+0 ratio = 2.11E+0 ratio_2 = 1.65E+0
cutoff = 1.45E+0 ratio = 2.11E+0 ratio_2 = 1.65E+0
cutoff = 1.50E+0 ratio = 2.09E+0 ratio_2 = 1.62E+0
cutoff = 1.55E+0 ratio = 2.09E+0 ratio_2 = 1.62E+0
cutoff = 1.60E+0 ratio = 2.09E+0 ratio_2 = 1.62E+0
cutoff = 1.65E+0 ratio = 2.09E+0 ratio_2 = 1.62E+0
cutoff = 1.70E+0 ratio = 2.09E+0 ratio_2 = 1.62E+0
cutoff = 1.75E+0 ratio = 2.09E+0 ratio_2 = 1.62E+0
cutoff = 1.80E+0 ratio = 2.01E+0 ratio_2 = 1.55E+0
cutoff = 1.85E+0 ratio = 2.01E+0 ratio_2 = 1.55E+0
cutoff = 1.90E+0 ratio = 1.98E+0 ratio_2 = 1.51E+0
cutoff = 1.95E+0 ratio = 1.98E+0 ratio_2 = 1.51E+0
cutoff = 2.00E+0 ratio = 1.98E+0 ratio_2 = 1.51E+0
|