with DC_Neur, Text_IO;
use  DC_Neur, Text_IO;

procedure ANN is
----------------------------------------------------------------------
----------------------------------------------------------------------
  package Float_IO is new Float_IO ( float );
  use Float_IO;
  DumStr: string ( 1..1 );
  DumNat: natural;
  Input_Count: positive;
begin
  Input_Count := States_Count ( "XOR.INP" );
  Put_Line ( "Input_Count: " & integer'image ( Input_Count ) );
  declare
    Input_File,
    Output_File : File_Type;
    Input_Set: integer := 0;
    Input_States: States_Type ( 1..Input_Count ) := ( others => 0.0 );
    Previous_States: States_Type ( 1..Input_Count ) := Input_States;
    Read_OK,
    Write_OK: boolean;
    First_Time: boolean := true;
    T1: string ( 1..7 ) := "XOR.TR1";
    T2: string ( 1..7 ) := "XOR.TR2";
    Temp: string ( 1..7 );
  begin
    Open ( Input_File, In_File, "XOR.INP" );
    Create ( Output_File, Out_File, "XOR.OUT" );
    loop
      Input_Set := Input_Set + 1;
      States_Read ( Input_File, Input_States, Read_OK );
      exit when not Read_OK;
      Put_Line ( "Input_Set" & integer'image ( Input_Set ) );
      loop
	States_Write ( Output_File, Input_States, Write_OK );
	Previous_States := Input_States;
	if First_Time then
	  Input_States := Net ( Input_States, "XOR.WGT", T1 );
	  First_Time := false;
	else
	  Input_States := Net ( Input_States, T1, T2 );
	  Temp := T1;
	  T1 := T2;
	  T2 := Temp;
	end if;
	exit when Input_States = Previous_States;
      end loop;
    end loop;
    Close ( Input_File );
    Close ( Output_File );
  end; -- declaration
----------------------------------------------------------------------
----------------------------------------------------------------------
end ANN;
