LoveBrains  1.0.0
physics.h
1 /*
2 ** physics.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 Wed Jul 22 14:41:22 2015 Guillaume ROBIN
8 ** Last update Mon Aug 24 14:17:19 2015 Guillaume ROBIN
9 */
10 
11 #ifndef PHYSICS_H_
12 # define PHYSICS_H_
13 
14 # include <vector>
15 # include <map>
16 
17 # include "Graphics/factory_object.h"
18 # include "Graphics/i_collider.h"
19 # include "Graphics/i_sensor.h"
20 # include "GA/i_dna.h"
21 
22 namespace Graphics
23 {
28  class Physics
29  {
30  public:
34  Physics(void);
38  ~Physics(void);
39 
40  /*
41  ** Getters.
42  */
43 
48  std::vector<ICollider *> const& getColliders(void) const;
53  std::vector<ISensor *> const& getSensors(void) const;
54  /* TODO: maybe optimize those 3 maps */
59  std::map<std::string, int> const& getEnvironmentSettings(void) const;
64  std::map<std::string, int> const& getCurrentEnvironment(void) const;
69  std::map<std::string, bool> const& getGenerationSettings(void) const;
70 
71  /*
72  ** Setters.
73  */
74 
79  void addCollider(ICollider *collider);
84  void addSensor(ISensor *sensor);
90  void addGenerationSetting(std::string type, bool generate);
91 
92  /*
93  ** Methods.
94  */
95 
100  void LoadEnvironmentSettings(std::list<IObject *>& env);
105  void UpdateEnvironment(std::list<IObject *>& env);
110  void UpdateColliders(std::list<IObject *>& env) const;
115  void UpdateSensors(std::list<IObject *>& env) const;
121  void GenerateEnvironment(std::list<IObject *>& env, std::list<GA::IDNA *>& brains);
127  void GenerateTournament(std::list<IObject *>& env, std::list<GA::IDNA *>& brains);
128 
129  /*
130  ** Overload.
131  */
132  Physics& operator=(Physics const& physics);
133 
134  private:
135  FactoryObjects _factory;
136  std::vector<ICollider *> _colls;
137  std::vector<ISensor *> _sensors;
138  std::map<std::string, int> _env_settings;
139  std::map<std::string, bool> _gen_settings;
140  std::map<std::string, int> _cur_settings;
141  };
142 }
143 
144 #endif /* !PHYSICS_H_ */
void addCollider(ICollider *collider)
Add a new collider to the physics engine.
Definition: physics.cc:73
void LoadEnvironmentSettings(std::list< IObject * > &env)
Load the environment settings from the environment.
Definition: physics.cc:107
std::map< std::string, int > const & getEnvironmentSettings(void) const
Get the environment settings that are contained in a map.
Definition: physics.cc:55
std::map< std::string, bool > const & getGenerationSettings(void) const
Get the generation settings that are contained in a map.
Definition: physics.cc:65
void addGenerationSetting(std::string type, bool generate)
Add a new generator setting to the physics engine.
Definition: physics.cc:85
void GenerateEnvironment(std::list< IObject * > &env, std::list< GA::IDNA * > &brains)
Generate the environment in terms of the environment settings.
Definition: physics.cc:206
std::vector< ISensor * > const & getSensors(void) const
Get all the sensors that are managed by the physics engine.
Definition: physics.cc:50
Define the interface of a sensor.
Definition: i_sensor.h:25
void addSensor(ISensor *sensor)
Add a new sensor to the physics engine.
Definition: physics.cc:79
~Physics(void)
Destructor.
Definition: physics.cc:34
std::vector< ICollider * > const & getColliders(void) const
Get all the colliders that are managed by the physics engine.
Definition: physics.cc:45
void UpdateSensors(std::list< IObject * > &env) const
Update all the sensors in the physics engine.
Definition: physics.cc:194
Define a factory of objects that will fill the environment in term of the environment file...
Definition: factory_object.h:23
Contains all the class that define the graphic environment.
void GenerateTournament(std::list< IObject * > &env, std::list< GA::IDNA * > &brains)
Generate the environment in terms of the environment settings for the tournament. ...
Definition: physics.cc:239
Define the interface for the collider object.
Definition: i_collider.h:22
Physics(void)
Constructor.
Definition: physics.cc:30
std::map< std::string, int > const & getCurrentEnvironment(void) const
Get the current state of the environment settings that are contained in a map.
Definition: physics.cc:60
void UpdateColliders(std::list< IObject * > &env) const
Update all the colliders in the physics engine.
Definition: physics.cc:170
void UpdateEnvironment(std::list< IObject * > &env)
Update the environment.
Definition: physics.cc:130
Define the physics engine used by the environment.
Definition: physics.h:28