LoveBrains  1.0.0
environment.h
1 /*
2 ** environment.h for LoveBrains in /home/robin_f/Programming/Git/CPP/LoveBrains
3 **
4 ** Made by Guillaume ROBIN
5 ** Login <robin_f@epitech.eu>
6 **
7 ** Started on Thu Jul 23 11:39:20 2015 Guillaume ROBIN
8 ** Last update Tue Aug 25 12:13:20 2015 Guillaume ROBIN
9 */
10 
11 #ifndef ENVIRONMENT_H_
12 # define ENVIRONMENT_H_
13 
14 # include <SFML/Graphics.hpp>
15 
16 # include "Graphics/i_object.h"
17 # include "Graphics/i_brain.h"
18 # include "Graphics/physics.h"
19 # include "GA/a_observable.h"
20 
25 namespace Graphics
26 {
32  {
33  public:
37  Environment2D(void);
43  Environment2D(unsigned int width, unsigned int height);
47  ~Environment2D(void);
48 
49  /*
50  ** Getters.
51  */
52 
57  std::list<IObject *> const& getObjects(void) const;
62  std::list<IObject *>& getObjects(void);
67  Physics const& getPhysics(void) const;
72  Physics& getPhysics(void);
77  sf::RenderWindow& getWindow(void);
78 
79  /*
80  ** Setters.
81  */
82 
87  void LoadFromFile(const char *path);
92  void setIsTournament(bool isTournament);
97  void setDisplay(bool display);
98 
99  /*
100  ** Overload.
101  */
102  Environment2D& operator=(Environment2D const& env);
103 
104  /*
105  ** Methods.
106  */
107 
112  void Update(sf::Time elapsed);
116  void Draw(void);
121  void Run(std::list<GA::IDNA *>& brains);
122 
123  private:
124  bool _display;
125  bool _isTournament;
126  unsigned int _num_epochs;
127  std::list<IObject *> _env;
128  sf::Font _font;
129  sf::Text _best_fitness;
130  sf::Text _avg_fitness;
131  sf::Text _epochs;
132  Physics _physics;
133  static sf::RenderWindow _window;
138  void UpdateInfos(void);
139  };
140 }
141 
142 #endif /* !ENVIRONMENT_H_ */
void setDisplay(bool display)
Set if the environment has to create a window.
Definition: environment.cc:192
void Run(std::list< GA::IDNA * > &brains)
Run the simulation with the graphic environment.
Definition: environment.cc:315
Define the abstract class that allow to be observable.
Definition: a_observable.h:28
void setIsTournament(bool isTournament)
Set if the current environment is a tournament or not.
Definition: environment.cc:187
Physics const & getPhysics(void) const
Get the physics engine member.
Definition: environment.cc:83
void Draw(void)
Draw all the objects on the window.
Definition: environment.cc:247
Environment2D(void)
Constructor.
Definition: environment.cc:34
void Update(sf::Time elapsed)
Update all the objects contains in the environment.
Definition: environment.cc:232
Contains all the class that define the graphic environment.
void LoadFromFile(const char *path)
Load the environment from the environment file given in parameters of LoveBrains. ...
Definition: environment.cc:145
~Environment2D(void)
Destructor.
Definition: environment.cc:64
std::list< IObject * > const & getObjects(void) const
Get all the objects of the environment.
Definition: environment.cc:73
Define the physics engine used by the environment.
Definition: physics.h:28
Definition: environment.h:31
sf::RenderWindow & getWindow(void)
Get the sf::RenderWindow member.
Definition: environment.cc:93