with DC_Keyb;
with DC_Scrn; use DC_Scrn;

procedure Percept is
---------------------------------------------------------------------------
  Rate     : constant float := 0.1;
  Weight   :          float := -2.0;
  Examples : constant array ( 1..5 ) of float
    := ( -1.0, -0.5, 0.0, 0.5, 1.0 );
  Classes  : constant array ( 1..5 ) of float
    := ( +1.0, -1.0, -1.0, -1.0, +1.0 );
  Dot : float;
  Change : float;
begin
  loop
    for X in Examples'range loop
      Put ( Weight );
      Put ( "  " ); Put ( Examples ( X ) );
      Dot := Classes ( X ) * ( Examples ( X ) - Weight );
      Put ( "  " ); Put ( Dot );
      if Dot <= 0.0 then
	Change := Rate * ( Examples ( X ) - Weight );
      else
	Change := 0.0;
      end if;
      Put ( "  " ); Put ( Change );
      Weight := Weight + Change;
      Put ( "  " ); Put ( Weight );
      Put_Line ( "" );
    end loop;
    DC_Keyb.Pause;
    Put_Line ( "------------" );
  end loop;
end Percept;
