BlueGit

blue-star cellular-evolution

fix NaN

timfa Tim · pushed by timfa

Authored 2021-10-13 · 5 years ago

Hash
a013e21b861630af78c67b28a05edb54a00acc07
Parent
7080b339
4 files changed +20 −10
js/game.js +8 −5
@@ -6,6 +6,7 @@ var cell =
6 6 {
7 7 localPos: new vector(0, 0),
8 8 parentCreature: null,
9 type: -1,
9 10 cellRef: -1,
10 11 currentSensorSignal: 0, //only used for sensors, else forever zero
11 12 lastSum: 0, //used for debug purposes
@@ -34,13 +35,17 @@ var cell =
34 35
35 36 update: function()
36 37 {
37 var rotated = this.localPos.rotate(this.parentCreature.transform.rotation);
38 this.transform.position = rotated.stretch(this.transform.scale.x).add(this.parentCreature.transform.position);
38 var rotated = this.localPos.rotate(this.parentCreature.transform.rotation);
39 this.transform.position = rotated.stretch(this.transform.scale.x).add(this.parentCreature.transform.position);
40
41 if(this.type == TYPES.EYE)
42 this.transform.rotation = this.localPos.toAngle();
39 43 },
40 44
41 45 setType: function(typeID)
42 46 {
43 47 this.renderer.subImage = typeID;
48 this.type = typeID;
44 49 }
45 50 }
46 51
@@ -137,9 +142,7 @@ var creature =
137 142 {
138 143 for(var i = 0; i < this.dna[cellInstance.cellRef].inputs.length; i++)
139 144 {
140 sum += sigmoid(this.getCellInputSum(
141 this.findCellInstanceByCellId(this.dna[cellInstance.cellRef].inputs[i].id)
142 , tracer) * this.dna[cellInstance.cellRef].inputs[i].weight);
145 sum += sigmoid(this.getCellInputSum(this.findCellInstanceByCellId(this.dna[cellInstance.cellRef].inputs[i].id), tracer) * this.dna[cellInstance.cellRef].inputs[i].strength);
143 146 }
144 147 }
145 148
@@ -6,6 +6,7 @@ var cell =
6{
6{
7 localPos: new vector(0, 0),
7 localPos: new vector(0, 0),
8 parentCreature: null,
8 parentCreature: null,
9 type: -1,
9 cellRef: -1,
10 cellRef: -1,
10 currentSensorSignal: 0, //only used for sensors, else forever zero
11 currentSensorSignal: 0, //only used for sensors, else forever zero
11 lastSum: 0, //used for debug purposes
12 lastSum: 0, //used for debug purposes
@@ -34,13 +35,17 @@ var cell =
34
35
35 update: function()
36 update: function()
36 {
37 {
37 var rotated = this.localPos.rotate(this.parentCreature.transform.rotation);
38 var rotated = this.localPos.rotate(this.parentCreature.transform.rotation);
38 this.transform.position = rotated.stretch(this.transform.scale.x).add(this.parentCreature.transform.position);
39 this.transform.position = rotated.stretch(this.transform.scale.x).add(this.parentCreature.transform.position);
40
41 if(this.type == TYPES.EYE)
42 this.transform.rotation = this.localPos.toAngle();
39 },
43 },
40
44
41 setType: function(typeID)
45 setType: function(typeID)
42 {
46 {
43 this.renderer.subImage = typeID;
47 this.renderer.subImage = typeID;
48 this.type = typeID;
44 }
49 }
45}
50}
46
51
@@ -137,9 +142,7 @@ var creature =
137 {
142 {
138 for(var i = 0; i < this.dna[cellInstance.cellRef].inputs.length; i++)
143 for(var i = 0; i < this.dna[cellInstance.cellRef].inputs.length; i++)
139 {
144 {
140 sum += sigmoid(this.getCellInputSum(
145 sum += sigmoid(this.getCellInputSum(this.findCellInstanceByCellId(this.dna[cellInstance.cellRef].inputs[i].id), tracer) * this.dna[cellInstance.cellRef].inputs[i].strength);
141 this.findCellInstanceByCellId(this.dna[cellInstance.cellRef].inputs[i].id)
142 , tracer) * this.dna[cellInstance.cellRef].inputs[i].weight);
143 }
146 }
144 }
147 }
145
148
js/lastbuild.txt +4 −0
@@ -58,3 +58,7 @@
58 58 -13-10-2021- 12:56
59 59 -13-10-2021- 13:00
60 60 -13-10-2021- 13:14
61 -13-10-2021- 13:23
62 -13-10-2021- 13:24
63 -13-10-2021- 13:27
64 -13-10-2021- 13:28
@@ -58,3 +58,7 @@
58-13-10-2021- 12:56
58-13-10-2021- 12:56
59-13-10-2021- 13:00
59-13-10-2021- 13:00
60-13-10-2021- 13:14
60-13-10-2021- 13:14
61-13-10-2021- 13:23
62-13-10-2021- 13:24
63-13-10-2021- 13:27
64-13-10-2021- 13:28
src/cell.js +7 −2
@@ -6,6 +6,7 @@ var cell =
6 6 {
7 7 localPos: new vector(0, 0),
8 8 parentCreature: null,
9 type: -1,
9 10 cellRef: -1,
10 11 currentSensorSignal: 0, //only used for sensors, else forever zero
11 12 lastSum: 0, //used for debug purposes
@@ -34,12 +35,16 @@ var cell =
34 35
35 36 update: function()
36 37 {
37 var rotated = this.localPos.rotate(this.parentCreature.transform.rotation);
38 this.transform.position = rotated.stretch(this.transform.scale.x).add(this.parentCreature.transform.position);
38 var rotated = this.localPos.rotate(this.parentCreature.transform.rotation);
39 this.transform.position = rotated.stretch(this.transform.scale.x).add(this.parentCreature.transform.position);
40
41 if(this.type == TYPES.EYE)
42 this.transform.rotation = this.localPos.toAngle();
39 43 },
40 44
41 45 setType: function(typeID)
42 46 {
43 47 this.renderer.subImage = typeID;
48 this.type = typeID;
44 49 }
45 50 }
@@ -6,6 +6,7 @@ var cell =
6{
6{
7 localPos: new vector(0, 0),
7 localPos: new vector(0, 0),
8 parentCreature: null,
8 parentCreature: null,
9 type: -1,
9 cellRef: -1,
10 cellRef: -1,
10 currentSensorSignal: 0, //only used for sensors, else forever zero
11 currentSensorSignal: 0, //only used for sensors, else forever zero
11 lastSum: 0, //used for debug purposes
12 lastSum: 0, //used for debug purposes
@@ -34,12 +35,16 @@ var cell =
34
35
35 update: function()
36 update: function()
36 {
37 {
37 var rotated = this.localPos.rotate(this.parentCreature.transform.rotation);
38 var rotated = this.localPos.rotate(this.parentCreature.transform.rotation);
38 this.transform.position = rotated.stretch(this.transform.scale.x).add(this.parentCreature.transform.position);
39 this.transform.position = rotated.stretch(this.transform.scale.x).add(this.parentCreature.transform.position);
40
41 if(this.type == TYPES.EYE)
42 this.transform.rotation = this.localPos.toAngle();
39 },
43 },
40
44
41 setType: function(typeID)
45 setType: function(typeID)
42 {
46 {
43 this.renderer.subImage = typeID;
47 this.renderer.subImage = typeID;
48 this.type = typeID;
44 }
49 }
45}
50}
src/creature.js +1 −3
@@ -91,9 +91,7 @@ var creature =
91 91 {
92 92 for(var i = 0; i < this.dna[cellInstance.cellRef].inputs.length; i++)
93 93 {
94 sum += sigmoid(this.getCellInputSum(
95 this.findCellInstanceByCellId(this.dna[cellInstance.cellRef].inputs[i].id)
96 , tracer) * this.dna[cellInstance.cellRef].inputs[i].weight);
94 sum += sigmoid(this.getCellInputSum(this.findCellInstanceByCellId(this.dna[cellInstance.cellRef].inputs[i].id), tracer) * this.dna[cellInstance.cellRef].inputs[i].strength);
97 95 }
98 96 }
99 97
@@ -91,9 +91,7 @@ var creature =
91 {
91 {
92 for(var i = 0; i < this.dna[cellInstance.cellRef].inputs.length; i++)
92 for(var i = 0; i < this.dna[cellInstance.cellRef].inputs.length; i++)
93 {
93 {
94 sum += sigmoid(this.getCellInputSum(
94 sum += sigmoid(this.getCellInputSum(this.findCellInstanceByCellId(this.dna[cellInstance.cellRef].inputs[i].id), tracer) * this.dna[cellInstance.cellRef].inputs[i].strength);
95 this.findCellInstanceByCellId(this.dna[cellInstance.cellRef].inputs[i].id)
96 , tracer) * this.dna[cellInstance.cellRef].inputs[i].weight);
97 }
95 }
98 }
96 }
99
97