-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlanta.js
48 lines (39 loc) · 1.01 KB
/
Planta.js
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
class Planta {
constructor(x, y, e, f, dna,cor) {
this.dna = dna;
this.rootX = x;
this.rootY = y;
this.cau = [];
this.cor = cor;
this.cau [ 0 ] =new Caule(this.rootX, this.rootY, e, f, this.dna.genes[0],this.cor);
}
grow() {
this.cau[this.cau.length]=new Caule(this.cau[this.cau.length-1].x2, this.cau[this.cau.length-1].y2, this.cau[this.cau.length-1].dX, this.cau[this.cau.length-1].dY, this.dna.genes[this.cau.length],this.cor);
}
plant() {
for (let i = 0; i< this.cau.length; i++) {
this.cau[i].show();
}
}
/*
calcfitness(sec, w){
let dado =1;
for (let i = 0; i< sec; i++) {
if(this.cau[i].dirX==w[0][i]&&this.cau[i].dirY==w[1][i]){
this.score+=3*dado;
dado++;
} else{
this.score--;
dado=1;
}
}
this.score=this.score*dado;
if (this.score<0) this.score=0;
}*/
get novo(){
let n = this;
n.cau= new Caule[1];
n.cau[0]=new Caule(rootX, rootY, 0, -1, dna.genes[0]);
return n;
}
}