[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

97.0. "Die" by ORPHAN::BRETT () Wed Jul 25 1984 19:10

Consider the following algorithm from a board game...

	two (largish) armies face each other, label one the Aggressor and
	the other the Defender.

	The aggressor throws three die.

	The defender throws either one, two, or three die at his preference.

	The two sets of die are sorted and compared against corresponding
	opposition die.

	If the aggressors die is HIGHER than the defender, the defender looses
	one man, otherwise the aggressor looses one man.

Question:
	For any given aggressor throw, how many should the defender throw?
	Given this strategy, what is the ratio of aggressors to defenders
	lost?

I have a Pascal program that answers this by brute force, but the mathematical
issues for any other approach get very tangled...

/Bevin
T.RTitleUserPersonal
Name
DateLines
97.1ORPHAN::BRETTWed Jul 25 1984 19:1213
Eg:	Aggressor 652	Defender 553

	6 v 5 - defender looses 1
	5 v 5 - aggressor looses 1
	2 v 3 - ditto


	Aggressor 652	Defender 5

	6 v 5 - defender loses 1

/Bevin
97.2LAMBDA::VOSBURYThu Jul 26 1984 11:234
When does the defender decide how many dice to throw?  Before both throw or
after the agressor has thrown and he can see the pips?

Mike.
97.3ORPHAN::BRETTThu Jul 26 1984 13:446
AFTER the aggressor has thrown, but before the defender throws.

/Bevin

PS: As Stan guessed - the game is Risk.
97.4ORPHAN::BRETTFri Jul 27 1984 20:24339
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
97.5AURORA::HALLYBFri Aug 03 1984 02:4215
Another problem (and anecdote):  what does the defender do if his object
is to LOSE as quickly as possible?  Is it just the reverse of the above
strategy, or does the win-on-tie criterion unbalance things?

Why would you want to lose?  Well sometimes due to alliances you'd want
an ally to conquer some territory of yours in order to attack a third enemy.
Naturally you want to lose as fast as possible.

Anecdote:  when this situation occurred back in my college days, an ROTC
guy (playing defender-who-wants-to-lose) took the attitude of "I'll only
roll one die under any circumstances, that'll lessen my chance of getting
a 6".  I always disagreed with that approach, but if a guy is trying to lose
it was unfriendly to argue with him...

I suppose comments with no math content ought to go into PICA::SYS$NOTES:GAMES
97.6CSC02::DAMNETFri Dec 20 1985 10:4713
Are the RISK rules different from country to country? I was recently given
a French edition of RISK from PARKER (General Mills).
The rules leaflet says that the aggressor throws 1 to 3 dice, and the 
defender answers by throwing either 1 or 2 dice. The dice are then sorted
by decreasing order and the process is the same as mentioned in .0
That means we can have for example the aggressor throwing only one die, and
the defender throwing two...

How does this modifie the strategy given in previous replies? Is that rule
more equitable than the one in .0 ?

Jean-Luc DAMNET
Paris,France