Tests About Natural Selection In Virtual Environment
c
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

creature.h 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. Copyright (C) 2011 Weber Yann, Schuck Clement
  3. This file is part of Tansive.
  4. Tansive is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. Tansive is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with Tansive. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #ifndef CREATURE_H
  16. #define CREATURE_H
  17. #include<stdlib.h>
  18. #include<stdio.h>
  19. #include<string.h>
  20. #include<pthread.h>
  21. #include"config.h"
  22. #include"genome.h"
  23. /*
  24. creature.h :
  25. Define struct and functions about creature management.
  26. */
  27. //Store data about one creature
  28. typedef struct _t_creature
  29. {
  30. t_tree_genome *genome_tree;
  31. t_memory mem;
  32. int energy;
  33. int life;
  34. int timeleft;
  35. int reprotimer;
  36. pthread_mutex_t* mutex;
  37. int x;
  38. int y;
  39. }t_creature;
  40. //Store one creature in the chain
  41. typedef struct _t_chain_creature
  42. {
  43. t_creature *creat;
  44. struct _t_chain_creature *next;
  45. struct _t_chain_creature *prev;
  46. }t_chain_creature;
  47. //Return a pointer on a randomly generated creature
  48. t_creature* create_random_creature();
  49. //Return a pointer on a creature associated with the genome gnome
  50. t_creature* create_gnome_creature(t_tree_genome* gnome);
  51. //Usefull function to manage the t_chain_creature
  52. t_chain_creature* create_creature_chain(t_creature* first);
  53. t_chain_creature* add_creature_chain(t_chain_creature* lst_creat, t_creature* new_creat);
  54. t_chain_creature* del_creature_chain(t_chain_creature** lst_creat, t_creature* dead_creat);
  55. #endif