initial refactor to pheromone matrix

This commit is contained in:
churl
2022-05-15 17:06:47 +02:00
parent 725c69e54a
commit e1a9eb2beb
14 changed files with 64 additions and 201 deletions

View File

@ -3,6 +3,7 @@
#include "colony.hpp"
#include "food.hpp"
#include "main.hpp"
#include "pheromone_map.hpp"
#include "world_object.hpp"
#include <cmath>
@ -13,43 +14,43 @@
#include <SFML/Graphics.hpp>
#include <string>
const double speed = 1;
const double determination = 25; // straightness of the path
const unsigned int pheromone_interval = 5; // how many updates between drops
constexpr unsigned int speed = 1;
const unsigned int view_angle = 45; // angle degrees to each side
const unsigned int view_distance = 25; // more like smell distance
constexpr unsigned int view_angle = 45; // angle degrees to each side
constexpr unsigned int view_distance = 25; // more like smell distance
typedef enum {
NORTH,
EAST,
SOUTH,
WEST
} direction;
class Ant : public WorldObject {
double direction; // in radians
private:
// TODO: Switch direction to only N, E, S, W
direction dir; // in radians
// TODO: Should this be here or just global?
PheromoneMap& pheromones;
// TODO: Leave continuous trail and remove this
unsigned int next_pheromone_drop = 0;
PheroType pheromone_type = NONE; // FOOD, HOME, NONE
public:
// TODO: Why is this stored here? I guess it can be removed
// Contains the WorldObjects (other ants, base, food)
// TODO: Is this even needed?
std::vector<std::shared_ptr<WorldObject>> umwelt;
public:
Ant(PheromoneMap& pheromones, double x, double y);
Ant(PheromoneMap& pheromones, unsigned int direction);
explicit Ant(PheromoneMap& pheromones);
Ant(PheromoneMap& pheromones, double x, double y); // Just random direction
Ant(PheromoneMap& pheromones, unsigned int direction); // Just random position
explicit Ant(PheromoneMap& pheromones); // All random
// TODO: Regarding umwelt
void addToUmwelt(const std::shared_ptr<WorldObject>& object);
void update() override;
PheroType getPheromoneType() const override;
void move();
void updateAppearance();
void updatePheromones();
void dropPheromone(); // red
// TODO: Regarding umwelt
void updateUmwelt();
};
#endif