Program: 87347
Project: 87347
Buggy source:
/** 
 * Familiarisation learning extends the image in a node by adding new  information from the given pattern.
 */
Node familiarise(Chrest model,ListPattern pattern){
  ListPattern newInformation=pattern.remove(_image);
  if (newInformation.isEmpty()) {
    if (newInformation.isFinished()) {
      _image.setFinished();
    }
  }
 else {
    Node retrievedChunk=model.recognise(newInformation);
    if (retrievedChunk == model.getLtmByModality(pattern)) {
      return model.getLtmByModality(pattern).learnPrimitive(model,newInformation.getFirstItem());
    }
 else     if (retrievedChunk.getImage().isEmpty()) {
      ListPattern primitive=newInformation.getFirstItem();
      retrievedChunk=model.recognise(primitive);
      if (retrievedChunk == model.getLtmByModality(pattern)) {
        return model.getLtmByModality(pattern).learnPrimitive(model,primitive);
      }
 else {
        ListPattern toadd=primitive.clone();
        toadd.setNotFinished();
        _image=_image.append(toadd);
        model.advanceClock(model.getFamiliarisationTime());
      }
    }
 else     if (retrievedChunk.getImage().matches(newInformation)) {
      ListPattern toadd=retrievedChunk.getImage().clone();
      toadd.setNotFinished();
      _image=_image.append(toadd);
      model.advanceClock(model.getFamiliarisationTime());
    }
 else {
      ListPattern primitive=newInformation.getFirstItem();
      retrievedChunk=model.recognise(primitive);
      if (retrievedChunk == model.getLtmByModality(pattern)) {
        return model.getLtmByModality(pattern).learnPrimitive(model,primitive);
      }
 else {
        ListPattern toadd=primitive.clone();
        toadd.setNotFinished();
        _image=_image.append(toadd);
        model.advanceClock(model.getFamiliarisationTime());
      }
    }
  }
  return this;
}

Fixed version (ground truth):
/** 
 * Familiarisation learning extends the image in a node by adding new  information from the given pattern.
 */
Node familiarise(Chrest model,ListPattern pattern){
  ListPattern newInformation=pattern.remove(_image);
  if (newInformation.isEmpty()) {
    if (newInformation.isFinished()) {
      _image=_image.clone();
      _image.setFinished();
    }
  }
 else {
    Node retrievedChunk=model.recognise(newInformation);
    if (retrievedChunk == model.getLtmByModality(pattern)) {
      return model.getLtmByModality(pattern).learnPrimitive(model,newInformation.getFirstItem());
    }
 else     if (retrievedChunk.getImage().isEmpty()) {
      ListPattern primitive=newInformation.getFirstItem();
      retrievedChunk=model.recognise(primitive);
      if (retrievedChunk == model.getLtmByModality(pattern)) {
        return model.getLtmByModality(pattern).learnPrimitive(model,primitive);
      }
 else {
        ListPattern toadd=primitive.clone();
        toadd.setNotFinished();
        _image=_image.append(toadd);
        model.advanceClock(model.getFamiliarisationTime());
      }
    }
 else     if (retrievedChunk.getImage().matches(newInformation)) {
      ListPattern toadd=retrievedChunk.getImage().clone();
      toadd.setNotFinished();
      _image=_image.append(toadd);
      model.advanceClock(model.getFamiliarisationTime());
    }
 else {
      ListPattern primitive=newInformation.getFirstItem();
      retrievedChunk=model.recognise(primitive);
      if (retrievedChunk == model.getLtmByModality(pattern)) {
        return model.getLtmByModality(pattern).learnPrimitive(model,primitive);
      }
 else {
        ListPattern toadd=primitive.clone();
        toadd.setNotFinished();
        _image=_image.append(toadd);
        model.advanceClock(model.getFamiliarisationTime());
      }
    }
  }
  return this;
}