Beispiel #1
0
double to_samu ( int channel, SPOTriplets &tv )
{
  double r {0.0};

  try
    {
      samu.triplet ( channel, tv );
      r = samu.reward();
    }
  catch ( const char* err )
    {
      std::cerr << err << std::endl;
    }
  return r;
}
Beispiel #2
0
double to_samu ( int channel, std::string &msg )
{
  double r {0.0};

  try
    {
      samu.sentence ( channel, msg );
      r = samu.reward();
    }
  catch ( const char* err )
    {
      std::cerr << err << std::endl;
    }
  return r;
}
Beispiel #3
0
int main ( int argc, char **argv )
{

#ifndef Q_LOOKUP_TABLE
  std::string samuImage {"samu.image.txt"};

  std::fstream samuFile ( samuImage,  std::ios_base::in );
  if ( samuFile )
    samu.load ( samuFile );
#endif


  struct sigaction sa;
  sa.sa_handler = save_samu;
  sigemptyset ( &sa.sa_mask );
  sa.sa_flags = SA_RESTART;

  sigaction ( SIGINT, &sa, NULL );
  sigaction ( SIGTERM, &sa, NULL );
  sigaction ( SIGKILL, &sa, NULL );
  sigaction ( SIGHUP, &sa, NULL );

  // Do not remove this copyright notice!
  std::cout << "This program is Isaac, the son of Samu Bátfai."
            << std::endl
            << "Copyright (C) 2015 Norbert Bátfai"
            << std::endl
            << "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>"
            << std::endl
            << "This is free software: you are free to change and redistribute it."
            << std::endl
            << "There is NO WARRANTY, to the extent permitted by law."
            << std::endl
            << std::endl;


  std::cout << "The prenatal development phase has started."
            << std::endl;
  //
  std::cout << "The prenatal development phase has finished."
            << std::endl;


  std::string test[] =
  {
    "A rare black squirrel has become a regular visitor to a suburban garden",
    "This is a car",
    "This car is mine",
    "I have a little car",
    "The sky is blue",
    "The little brown bear has eaten all of the honey",
    "I love Samu"
  };

  int j {0};

  for ( ; samu.run(); )
    {
      double sum {0.0};
      if ( samu.sleep() )
        {
          for ( int i {0}; i<7; ++i )
            {
              samu << test[i];
              sum += samu.reward();

            }
          std::cerr << "###### " << ++j << "-th iter " << sum << std::endl;
        }
    }

  return 0;
}