/* Copyright (C) 2011 Weber Yann, Schuck Clement This file is part of Tansive. Tansive is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Tansive is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Tansive. If not, see . */ #ifndef _GENOME_H #define _GENOME_H #include #include #include"config.h" /* genome.h : Define struct, constantes and function for creature's genome management. */ //what does the creature eat #define GNOME_VEGAN 1 #define GNOME_CARNI 2 //Various genome caracteristic's limit #define GNOME_MIN_WEIGHT 0 #define GNOME_MAX_WEIGHT 100 #define GNOME_MAX_STRENGHT 100 #define GNOME_MIN_LIFE 10 #define GNOME_MAX_LIFE 100 #define GNOME_MIN_SPEED 2 #define GNOME_MAX_SPEED 6 #define GNOME_MAX_ENERGY 100 #define GNOME_MAX_AGGRESSION 100 #define GNOME_MAX_PERCEP 10 #define GNOME_MAX_LIFETIME 500 #define GNOME_MIN_LIFETIME 100 #define GNOME_MIN_NBCHILD 1 #define GNOME_MAX_NBCHILD 5 #define GNOME_MIN_REPROFREQ 10 #define GNOME_MAX_REPROFREQ 100 //Memorie limits #define GNOME_MAX_MEM_SIZE 100 #define GNOME_MEMORYCAP_FOOD 1 #define GNOME_MEMORYCAP_DANGER 2 #define GNOME_MEMORYCAP_TARGET 4 #define GNOME_MEMORY_ELTTYPE_FOOD 1 #define GNOME_MEMORY_ELTTYPE_DANGER 2 #define GNOME_MEMORY_ELTTYPE_TARGET 3 #define GNOME_MEMORYTYPE_RAND 1 #define GNOME_MEMORYTYPE_BOUCLE 2 #define GNOME_MEMORYTYPE_INT 3 //Mutation constants #define GNOME_MUTATION_CHANCE 500 #define GNOME_MUTATION_MIN 3 #define GNOME_MUTATION_MAX 10 #define GNOME_MUTATION_GNOM_MODIF 10 //Name limits #define GNOME_MAX_NAMESIZE 10 #define GNOME_MIN_NAMESIZE 3 //Store one element of memorie typedef struct _t_mem_element { char type;//take value in GNOME_MEMORYTYPE_* int x; int y; }t_mem_element; //Represent the memory of the creature typedef struct _t_memory { t_mem_element* mem; }t_memory; /* This structure defined the caracteristics of a creature */ typedef struct _t_genome { int weight; //take value in [0..GNOME_MAX_WEIGHT] int strenght; //take value in [0..GNOME_MAX_STRENGHT] int life; //take value in [0..GNOME_MAX_LIFE] int speed; //take value in [0..GNOME_MAX_SPEED] int energy; //take value in [0..GNOME_MAX_ENERGY] int aggression; //take value in [0..GNOME_MAX_AGGRESSION] int perception; //take value in [0..GNOME_MAX_PERCEPT] int lifetime; //take value in [GNOME_MIN_LIFETIME..GNOME_MAX_LIFETIME] int nbchild; //take value in [GNOME_MIN_NBCHILD..GNOME_MAX_NBCHILD] int reprofreq; //take value in [GNOME_MIN_REPROFREQ..GNOME_MAX_REPROFREQ] char mem_capabilities; char mem_type; char mem_size; char food; //take value in GNOME_VEGAN or GNOME_CARNI char* name; //Stats about the genome unsigned long nb_creat; unsigned long nb_nat_dead; unsigned long nb_star_dead; unsigned long nb_figt_dead; unsigned long nb_eat_dead; }t_genome; //Store a node of a genome tree typedef struct _t_tree_genome { struct _t_tree_genome* parent; struct _t_tree_genome** child; unsigned long nb_child; t_genome gnome; }t_tree_genome; //Generate a random genome t_genome rand_genome(); //Return a genome with mutations t_genome mutation(t_genome orig); //Add a child to a node t_tree_genome* add_child_treegnome(t_tree_genome* t, t_tree_genome* child); //Initialize a node with a genome t_tree_genome* create_new_gnometree_node(t_genome gnome); //Print the genome tree on stdout void disp_genome_tree_info(t_tree_genome* t, char eq_zero); //Write the genome tree in graphviz's format on file void write_graphviz_genome_tree(FILE* file, t_tree_genome* t); //Return a random char, vowel or consonant char rand_char(char type); //return a random name char* rand_name(); //return !(rand()%proba) char calc_proba(int proba); #endif