// This file is a part of Framsticks SDK. http://www.framsticks.com/ // Copyright (C) 1999-2018 Maciej Komosinski and Szymon Ulatowski. // See LICENSE.txt for details. #ifndef _FL_OPER_H_ #define _FL_OPER_H_ #include "../genooperators.h" #include "fL_general.h" /** @name Codes for general fL mutation types */ //@{ #define FL_ADD_WORD 0 ///* list, fL_Word *definition, std::list::iterator it); /** * Selects axiom or one of rule's successors. * @param creature the object with defined axiom and rules * @param numparams reference holding the number of parameters that are available for this list, 0 for axiom * @param ruleid the index of the rule in rules structure or -1 if selected sequence is the axiom * @return pointer to a selected sequence */ std::list* selectRandomSequence(fL_Builder *creature, int &numparams, int &ruleid); /** * Selects word definition according to a method. Method is one of * values FL_ADD_STICK, FL_ADD_NEURO, FL_ADD_CONN, FL_ADD_ROT, FL_ADD_OTHER * etc. If FL_ADD_OTHER is chosen, then one of defined words is chosen. If * there are no defined words, then one of built-in words is chosen. * If FL_ADD_BRANCH is selected, then method returns NULL. * @param creature current genotype * @param method one of methods of addition * @return object defining one of genotype words, or NULL if branching method is used */ fL_Word* randomWordDefinition(fL_Builder *creature, int method); /** * Tries to find appropriate word in second creature that matches the word in first creature. * Firstly, it tries to check if some word is not already assigned to a word in second creature. * If the searching is successful, then appropriate word is used. Otherwise, method tries to find * word that matches by name and number of parameters, or at least by number of parameters and hasn't * been used already for other translation. If this is impossible, method creates new word definition * for the second creature. * @param from creature, from rule is taken * @param to creature, which takes the rule * @param fromword word from the first creature that needs to be translated * @param map hashmap for current assignments * @return word instance that need to be used by generated rule for the second genotype */ fL_Word* getAppropriateWord(fL_Builder *from, fL_Builder *to, fL_Word *fromword, std::unordered_map &map); /** * Migrates random rule from one creature to the other creature. * @param from creature, from rule is taken * @param to creature, which takes the rule * @param numselrules number of rules that need to be moved */ void migrateRandomRules(fL_Builder *from, fL_Builder *to, int numselrules); /** * Deletes branch from a given sequence starting from iterator. The deletion * removes only braces, not whole branch. * @param list current list that needs to be modified * @param openbranchposition the iterator pointing to the open branch word */ void deleteBranch(std::list *list, std::list::iterator openbranchposition); public: double operations[FL_OPCOUNT]; ///