// This file is a part of Framsticks SDK. http://www.framsticks.com/ // Copyright (C) 1999-2015 Maciej Komosinski and Szymon Ulatowski. // See LICENSE.txt for details. // Copyright (C) 1999,2000 Adam Rotaru-Varga (adam_rotaru@yahoo.com), GNU LGPL #ifndef _F4_GENERAL_H_ #define _F4_GENERAL_H_ #include #include #include #include #ifdef DMALLOC #include #endif /** * Performs single rotation angle decrementation on a given value. * @param v pointer to the decremented value */ void rolling_dec(double * v); /** * Performs single rotation angle incrementation on a given value. * @param v pointer to the incremented value */ void rolling_inc(double * v); class f4_node; // later class f4_Cell; // later class f4_Cells; // later /** @name Types of f4_Cell's */ //@{ #define T_UNDIFF4 40 ///, ]. It runs recursively when opening braces * like (, <, # are found. * @param s string with the f4 genotype * @param slen length of a given string * @param stopchar character to be found * @return 1 if end of string was reached, or position of found character in sequence */ int scanrec(const char * s, unsigned int slen, char stopchar); class f4_CellLink; /** @name Constraints of f4 genotype structures */ //@{ #define MAXINPUTS 100 ///' character, appears. After the * '>' character, the cell is duplicated as many times as it is defined after the * repetition marker. */ class repeat_stack { public: repeat_stack() { top = 0; } inline void clear() { top = 0; } /** * Pushes repeat_ptr object onto the stack. If the stack size is exceeded, then no * information is provided. * @param rn repetition node info */ inline void push(repeat_ptr rn) { if (top >= stackSize) return; ptr[top] = rn; top++; } inline void pop() { if (top > 0) top--; } /** * Gets the current top element. * @return pointer to the element on top of the repeat_stack object */ inline repeat_ptr* first() { return &(ptr[top - (top > 0)]); }; static const int stackSize = 4; ///' (end of cell development without differentiation), * - the stack of repetition marker '#' will exceed maximum allowed value of repetition, * - the stick modifiers, like rotation, will be applied on neuron cell, * - the differentiated cell will be differentiated again, * - the neuron class inside cell connection (i.e. N[G:5]) is not a sensor, * - the connection between neurons cannot be established, * - the neuron class is not valid. * * @return 0 if development was successful, 1 if there was an error in genotype tree */ int onestep(); /** * Adds a link between this neuron cell and a given neuron cell in nfrom. If the nfrom object * is not given, neuron type in nt should be a sensor type. * @param nfrom input neuron cell, or NULL if not given * @param nw weight of connection * @param nt empty string or name of sensor class * @return 0 if link is established, -1 otherwise */ int addlink(f4_Cell *nfrom, double nw, string nt); /** * Adjusts properties of stick objects. */ void adjustRec(); int name; ///=childcount) double rolling; ///