<commit_before>#include "nevil/grandparent_arena.hpp"

nevil::grandparent_arena::grandparent_arena()
  : nevil::arena()
{}

nevil::grandparent_arena::grandparent_arena(int world_size_x, int world_size_y,bool has_parent, bool has_grandparent)
 : nevil::arena(world_size_x, world_size_y)
 , _has_parent(has_parent)
 , _has_grandparent(has_grandparent)
{

  Enki::Color switch_off_color(0.4, 0.0, 1.0);
  Enki::Color switch_on_color(0.9, 1.0, 1.0);

  //switch A
  _add_object("switch A", new nevil::switch_object(
    world_size_x * (5/ 8.0)  // x coordinate
    , 0                      // y coordinate
    , 6                      // size x
    , 0.1                    // size y
    , 7                      // height
    , switch_off_color       // Off color
    , switch_on_color));     // On color
  
  //switch B
  _add_object("switch B", new nevil::switch_object(
    world_size_x * (5/ 8.0)  // x coordinate
    , world_size_y           // y coordinate
    , 6                      // size x
    , 0.1                    // size y
    , 7                      // height
    , switch_off_color       // Off color
    , switch_on_color));     // On color
  
  //light
  _add_object("light", new nevil::light(0, world_size_y / 2.0, 0.1, 6));

  //--robots--
  // Create a robot named child with 0 degree angle
  _add_robot(new nevil::grandparent_robot(world_size_x / 4.0
    , world_size_y / 2.0
    , 0
    , _has_parent
    , _has_grandparent
    , "child"
    , Enki::Color(0.0, 0.0, 0.5)));

  // Create a robot named parent with 0 degree angle
  if (_has_parent)
  {
    _add_robot(new nevil::grandparent_robot(world_size_x / 2.0
      , world_size_y / 2.0
      , 0
      , _has_parent
      , _has_grandparent
      , "parent"
      , Enki::Color(0.0, 0.5, 0.0)));
  }

  // Create a robot named grandparent with 0 degree angle
  if (_has_grandparent)
  {
    _add_robot(new nevil::grandparent_robot(world_size_x * (3 / 4.0)
      , world_size_y / 2.0
      , 0
      , _has_parent
      , _has_grandparent
      , "grandparent"
      , Enki::Color(0.9, 0.0, 0.0)));
  }
}

void nevil::grandparent_arena::set_individuals(nevil::grandparent_individual *child
  , nevil::grandparent_individual *parent
  , nevil::grandparent_individual *grandparent)
{
  _robots[0]->set_individual(child);
  if (_has_parent)
    _robots[1]->set_individual(parent);
  if (_has_grandparent)
    _robots[2]->set_individual(grandparent);
}

bool nevil::grandparent_arena::update()
{
  nevil::arena::update();
  // Updating the environment
  for (auto r : _robots)
  {
    // Turning the switches and lights on based on the position of the robots
    if(r->is_at(_objects.at("switch A"), OFF))
    {
      _objects.at("switch A")->turn_on();
      _objects.at("light")->turn_on();
    }

    else if(r->is_at(_objects.at("switch B"), OFF))
    {
      _objects.at("switch B")->turn_on();
      _objects.at("light")->turn_on();
    }
  }

  // Updating the robots
  for (auto r : _robots)
    r->update(_objects);
  return true;
}<commit_msg>moved switch light interactions to grandparent_robot.cpp<commit_after>#include "nevil/grandparent_arena.hpp"

nevil::grandparent_arena::grandparent_arena()
  : nevil::arena()
{}

nevil::grandparent_arena::grandparent_arena(int world_size_x, int world_size_y,bool has_parent, bool has_grandparent)
 : nevil::arena(world_size_x, world_size_y)
 , _has_parent(has_parent)
 , _has_grandparent(has_grandparent)
{

  Enki::Color switch_off_color(0.4, 0.0, 1.0);
  Enki::Color switch_on_color(0.9, 1.0, 1.0);

  //switch A
  _add_object("switch A", new nevil::switch_object(
    world_size_x * (5/ 8.0)  // x coordinate
    , 0                      // y coordinate
    , 6                      // size x
    , 0.1                    // size y
    , 7                      // height
    , switch_off_color       // Off color
    , switch_on_color));     // On color
  
  //switch B
  _add_object("switch B", new nevil::switch_object(
    world_size_x * (5/ 8.0)  // x coordinate
    , world_size_y           // y coordinate
    , 6                      // size x
    , 0.1                    // size y
    , 7                      // height
    , switch_off_color       // Off color
    , switch_on_color));     // On color
  
  //light
  _add_object("light", new nevil::light(0, world_size_y / 2.0, 0.1, 6));

  //--robots--
  // Create a robot named child with 0 degree angle
  _add_robot(new nevil::grandparent_robot(world_size_x / 4.0
    , world_size_y / 2.0
    , 0
    , _has_parent
    , _has_grandparent
    , "child"
    , Enki::Color(0.0, 0.0, 0.5)));

  // Create a robot named parent with 0 degree angle
  if (_has_parent)
  {
    _add_robot(new nevil::grandparent_robot(world_size_x / 2.0
      , world_size_y / 2.0
      , 0
      , _has_parent
      , _has_grandparent
      , "parent"
      , Enki::Color(0.0, 0.5, 0.0)));
  }

  // Create a robot named grandparent with 0 degree angle
  if (_has_grandparent)
  {
    _add_robot(new nevil::grandparent_robot(world_size_x * (3 / 4.0)
      , world_size_y / 2.0
      , 0
      , _has_parent
      , _has_grandparent
      , "grandparent"
      , Enki::Color(0.9, 0.0, 0.0)));
  }
}

void nevil::grandparent_arena::set_individuals(nevil::grandparent_individual *child
  , nevil::grandparent_individual *parent
  , nevil::grandparent_individual *grandparent)
{
  _robots[0]->set_individual(child);
  if (_has_parent)
    _robots[1]->set_individual(parent);
  if (_has_grandparent)
    _robots[2]->set_individual(grandparent);
}

bool nevil::grandparent_arena::update()
{
  nevil::arena::update();

  // Updating the robots
  for (auto r : _robots)
    r->update(_objects);
  return true;
}
{'fraction_non_alphanumeric': 0.1318758815232722, 'fraction_numerical': 0.025740479548660086, 'mean_word_length': 2.397005988023952, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6855638', 'n_tokens_mistral': 2164, 'n_tokens_neox': 2036, 'n_words': 404}