with Free_Will, Expectancy;
use Free_Will, Expectancy;
with Text_Io;
use Text_Io;
with Interfaces.C;
use Interfaces;
with Calendar;
use Calendar;
procedure Main is
function system(Command : C.Char_Array) return C.Int;
pragma Import (C, System, "system" );
Errno : C.Int;
CFinality : Long_integer := 0;
CChaos : Long_integer := 0;
CEquality : Long_integer := 0;
save, Choice : T_Choice := Equality;
Date : Time := clock;
step : Duration := 1.0;
Freq_Chaos, Chaos_Per_Step : Natural := 0;
Freq_Finality, Finality_Per_Step : Natural := 0;
Freq_Equality, Equality_Per_Step : Natural := 0;
Tchaos : natural := 0;
Tfinality : natural := 0;
Tequality : natural := 0;
Left : Duration := 0.0;
begin
Reset;
loop
begin
Choice := Action;
case Choice is
when Finality =>
CFinality := CFinality + 1;
Finality_Per_Step := Finality_Per_Step + 1;
when Chaos =>
CChaos := CChaos + 1;
Chaos_Per_Step := Chaos_Per_Step + 1;
when Equality =>
CEquality := CEquality + 1;
Equality_Per_Step := Equality_Per_Step + 1;
end case;
Errno := System(C.To_C("cls" ));
if Choice = Finality then
Put("finality : * " & Long_Integer'Image(CFinality));
else
Put("finality : " & Long_Integer'Image(CFinality));
end if;
Put_Line(" freq : " & Natural'Image(Freq_Finality));
if Choice = Chaos then
Put("chaos : * " & Long_Integer'Image(CChaos));
else
Put("chaos : " & Long_Integer'Image(CChaos));
end if;
Put_Line(" freq : " & Natural'Image(Freq_Chaos));
if Choice = Equality then
Put("equality : * " & Long_Integer'Image(CEquality));
else
Put("equality : " & Long_Integer'Image(CEquality));
end if;
Put_Line(" freq : " & Natural'Image(Freq_Equality));
Put("Winner : " );
if Cfinality + CEquality > CChaos + CEquality then
Put_Line(T_Choice'Image(Finality));
if save /= finality then
Tfinality := Tfinality + 1;
save := finality;
end if;
elsif
Cfinality + CEquality < CChaos + CEquality then
Put_Line(T_Choice'Image(Chaos));
if save /= chaos then
Tchaos := Tchaos + 1;
save := chaos;
end if;
else
Put_Line(T_Choice'Image(Equality));
if save /= equality then
Tequality := Tequality + 1;
save := equality;
end if;
end if;
put_line("Count of transitions to : " );
put_line("Finality : " & natural'image(Tfinality));
put_line("Chaos : " & natural'image(TChaos));
put_line("Equality : " & natural'image(Tequality));
put_line("Midle count between tow transitions : " );
put_line("Finality : " & float'image(float(Cfinality)/(float(Tfinality)+Float(Tchaos)+Float(Tequality))));
put_line("Chaos : " & float'image(float(Cchaos)/(float(Tfinality)+Float(Tchaos)+Float(Tequality))));
put_line("Equality : " & float'image(float(Cequality)/(float(Tfinality)+Float(Tchaos)+Float(Tequality))));
case save is
when Finality =>
Life_Cycle.Finality;
when Chaos =>
Life_Cycle.Chaos;
when Equality =>
Life_Cycle.Equality;
end case;
Life_Cycle.Expectancy(Left);
Put("Time Left : " & Duration'Image(Left));
if Left < 0.0 then
exit;
end if;
delay 0.01 - (Clock - Date);
Date := Clock;
Step := Step - 0.01;
if Step = 0.0 then
Step := 1.0;
Freq_Chaos := Chaos_Per_Step;
Chaos_Per_Step := 0;
Freq_Finality := Finality_Per_Step;
Finality_Per_Step := 0;
Freq_Equality := Equality_Per_Step;
Equality_Per_Step := 0;
end if;
exception
when others =>
exit;
end;
end loop;
end Main;