/*************************************************************/ /* */ /* Interface for variable automata */ /* */ /*************************************************************/ /* Finite state machines Variable size Dan Ashlock 12/20/00 */ #ifndef _VAUT_H #define _VAUT_H //number of transitions out per state #define Vstates 4 //size of response alphabet #define VAsize 3 struct state{//responses are tied to transitions int resp[Vstates]; //responses 0=work 1=multiple 2=fail, 3=duh? int tran[Vstates]; //transitions C,G,A,T (0,1,2,3) }; class aut { //mealey machine class friend ostream &operator<<(ostream &,aut &); friend istream &operator>>(istream &,aut &); //two point crossover operator, non-aligned friend void tpc(aut &,aut &); // a <=== b friend void copy(aut &,aut &); //copy, with allocation if needed friend void upcopy(aut&,aut&); //as above but duplicates a state public: aut(); //create an empty automata aut(int nv); //create an automata with nv states aut(const aut &); //copy constructor ~aut(); //deallocate the automata //secondary initialization void create(int nv); //as the initializer aut(int nv) for populations void recreate(); //fill in a new automata void initTFT(); //reinitializes to stretched tit-for-tat //overloaded operators const aut &operator=(const aut &); //Self description int size(); //usage int reset(); //returns initial action int reset(int &wiis); //returns initial action and state int run(int inp); //run on input inp int run(int inp,int &stt); //run on input inp with given state //genetic operations, other than two point crossover void mutateaction(); //mutate an action void mutatetransition(); //mutate a transition void copystatemutation(); //copy a state, dealing out incoming arrows void initialmutation(); //mutate the initial state //assorted fitness functions int predict(int *ref,int bits); //string of bits and its length int selfdri(); //self driving length fitness funciton //I.O routines void printn(ostream &aus); //numerical (rather than PD metaphore) print private: int n; //number of states int inits; //initial state int inita; //initial action int cur; //current state state *states; }; #endif /* _VAUT_H */