forked from PhaseCycle/Biosystem-Simulation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFungus.cpp
77 lines (59 loc) · 1.78 KB
/
Fungus.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
Authors: Andrew Yoder, Thomas Stryjski, Zachary O'Brien
Date: 12/9/18
Class: EEEE-346-01
Assignment: Project 3
Purpose: Implementation of derived class for small fungi.
*/
#include "Fungus.h"
#include "Miscellaneous.h"
#include <cmath>
Fungus::Fungus(double x, double y, double z) {
consumption_amount = 2;
consumption_time = 5;
reproduction_amount = 2;
reproduction_time = 4;
reproduction_counter = reproduction_time;
consumption_food_counter = consumption_amount;
consumption_time_counter = consumption_time;
age = 0;
movement = 2;
spawn_distance = 4;
visibility = 1;
fertility = 2;
setLocation(x, y, z);
}
//getters
double Fungus::get_fertility() {
return fertility;
}
//setters
void Fungus::set_fertility() {
double temper = exp((-1/200) * pow((temperature - 25), 2));
fertility = 2 * temper * (1 + temper);
}
//other
void Fungus::reproduce(Fungus *O, double x_max, double y_max, double z_max) {
double theta, phi, x, y, z;
do {
theta = fRand(0, 2 * 3.14159265);
phi = fRand(0, 2 * 3.14159265);
x = spawn_distance * cos(phi) * cos(theta);
y = spawn_distance * cos(phi) * sin(theta);
z = spawn_distance * sin(phi);
} while((x > x_max) || (x < -(x_max)) || (y > y_max) || (y < -(y_max)) || (z > z_max) || (z < -(z_max)));
O->setLocation(x, y, z);
}
void Fungus::aged() {
age++;
movement = movement - (age/20); //decereases movement the older the cell is, although this is scaled by the constant 10. Accumulates
spawn_distance = 4 - (age / 100);//decreases spawn distance as the cell gets older, scaled by the constant 100. Acculmulates
}
Fungus Fungus::operator+(Bacteria *b) {
Point_3D newLocation = b->getLocation();
this->setLocation(newLocation);
dec_con_food_counter();
// delete b;
return *this;
}