Source:
public void mix(State state, ObjectInstance container) { ObjectClass complexIngredientClass = this.domain.getObjectClass(IngredientFactory.ClassNameComplex); Random rando = new Random(); Set<String> contents = ContainerFactory.getContentNames(container); String res; if (!(res = knowledgebase.canCombine(state, container)).equals("")) { knowledgebase.combineIngredients(state, domain, ingredient, container, res); } else { Set<ObjectInstance> hidden_copies = new HashSet<ObjectInstance>(); Set<String> traits = new TreeSet<String>(); Set<ObjectInstance> objects = new HashSet<ObjectInstance>(); for (String obj : contents) { objects.add(state.getObject(obj)); } ObjectInstance[] objectArray = new ObjectInstance[objects.size()]; objects.toArray(objectArray); for (String trait: IngredientFactory.getTraits(objectArray[0])) { if (IngredientFactory.getTraits(objectArray[1]).contains(trait)) { traits.add(trait); } } for (String name: contents) { ObjectInstance ing = state.getObject(name); if (!IngredientFactory.isSimple(ing)) { hidden_copies.add(IngredientFactory.makeHiddenObjectCopy(state, this.domain, ing)); } } ObjectInstance newIngredient = IngredientFactory.getNewComplexIngredientObjectInstance(complexIngredientClass, Integer.toString(rando.nextInt()), IngredientRecipe.generateAttributeNumber(false, false, false, false), false, container.getName(), traits, contents); state.addObject(newIngredient); ContainerFactory.removeContents(container); for (ObjectInstance ob : hidden_copies) { state.removeObject(state.getObject(ob.getName())); state.addObject(ob); } ContainerFactory.addIngredient(container, newIngredient.getName()); IngredientFactory.changeIngredientContainer(newIngredient, container.getName()); ExperimentHelper.checkIngredientCompleted(ingredient.makeFakeAttributeCopy(newIngredient), state, asList(newIngredient), state.getObjectsOfTrueClass(ContainerFactory.ClassName)); } }

Target:
private void mix(State state, ObjectInstance container) { ObjectClass complexIngredientClass = this.domain.getObjectClass(IngredientFactory.ClassNameComplex); Random rando = new Random(); Set<String> contents = ContainerFactory.getContentNames(container); String res; if (!(res = knowledgebase.canCombine(state, container)).equals("")) { this.combineIngredients(state, domain, ingredient, container, res); } else { Set<ObjectInstance> hidden_copies = new HashSet<ObjectInstance>(); Set<String> traits = new TreeSet<String>(); Set<ObjectInstance> objects = new HashSet<ObjectInstance>(); for (String obj : contents) { objects.add(state.getObject(obj)); } ObjectInstance[] objectArray = new ObjectInstance[objects.size()]; objects.toArray(objectArray); for (String trait: IngredientFactory.getTraits(objectArray[0])) { if (IngredientFactory.getTraits(objectArray[1]).contains(trait)) { traits.add(trait); } } for (String name: contents) { ObjectInstance ing = state.getObject(name); if (!IngredientFactory.isSimple(ing)) { hidden_copies.add(IngredientFactory.makeHiddenObjectCopy(state, this.domain, ing)); } } ObjectInstance newIngredient = IngredientFactory.getNewComplexIngredientObjectInstance(complexIngredientClass, Integer.toString(rando.nextInt()), Recipe.NO_ATTRIBUTES, false, container.getName(), traits, contents); state.addObject(newIngredient); ContainerFactory.removeContents(container); for (ObjectInstance ob : hidden_copies) { state.removeObject(state.getObject(ob.getName())); state.addObject(ob); } ContainerFactory.addIngredient(container, newIngredient.getName()); IngredientFactory.changeIngredientContainer(newIngredient, container.getName()); ExperimentHelper.checkIngredientCompleted(ingredient.makeFakeAttributeCopy(newIngredient), state, asList(newIngredient), state.getObjectsOfTrueClass(ContainerFactory.ClassName)); } }