-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimulatorBase.hpp
57 lines (48 loc) · 1.09 KB
/
SimulatorBase.hpp
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
#pragma once
#include <vector>
#include <string>
#include <iostream>
#include <cstring>
#include <cmath>
#include <fstream>
class Robot{
public:
std::vector<double> dots;// stride = 1
std::vector<double> springs;// stride = 4 //k, a*sin(wt + b) + c
std::vector<double> PVA;// stride = 9
void addDots(double m);
void addDots(double m, double x, double y, double z);
void addSprings();
static Robot* randomGenerate(int ndots);
int getIndex(int i, int j);
double energy;
};
class TwoPoints:public Robot{
public:
TwoPoints();
};
class BoxRobot:public Robot{
public:
BoxRobot();
};
class Simulator{
public:
std::vector<Robot*> robots;
double dt= 0.001;
int t = 0;
int step;
void update();
float* pos;
void output();
Simulator(double dt, int step);
~Simulator();
void randomAddRobots(int n_robot, int n_dots);
void mutate(double rate);
void crossOver();
void rankSelection();
};
// class SimNoGravity:public Simulator{
// public:
// SimNoGravity();
// void update() override;
// };