BlueGit

blue-star cellular-evolution

add creature death, heart, disconnected cells

timfa Tim · pushed by timfa

Authored 2021-10-09 · 5 years ago

Hash
49ad94bcaec41556aa1dae7b0094e7ea94c085cd
Parent
783a0223
1 file changed +5 −2
src/dnastring.js +5 −2
@@ -9,7 +9,7 @@
9 9 * definitions:
10 10 * - cell: one out of many objects of uniform size that make up a creature
11 11 * - sensor: a cell that is able to detect things
12 * - activator: a cell that can respond to the signal of a Synapse
12 * - activator: a cell that can respond to the signal of a Synapse, using energy from Stomach cells. When no energy is available, the Activators are unable to do anything and as such the creature will essentially be 'dead'
13 13 * - Synapse: a connection between a sensor and an activator
14 14 * - braincell: a cell that acts as a hybrid activator/sensor. It receives inputs like an activator would, but instead of doing something on its own, it has outbound Synapse connections of its own to one or more sensors (or other brain cells)
15 15 *
@@ -30,6 +30,7 @@
30 30 * OTHER
31 31 * - Stomach: Can contain energy. Each cell/pellet eaten increases energy in any available Stomach cells. All Activators require an amount of energy from any of the available Stomach cells to function.
32 32 * - Meat: A cell which does nothing except connect other cells. (and potentially function as armor)
33 * - Heart: Does nothing, but when the heart is destroyed the creature will die. Creature cannot have more than one Heart, which is always at 0,0
33 34 *
34 35 * A creature will multiply when all its Stomach cells are completely full, draining each of them by 50%. This spawns an Egg which will hatch into a copy of the parent creature with a slight mutation applied as soon as there is space available (read: the parent creature has moved suffficiently far away).
35 36 *
@@ -39,12 +40,14 @@
39 40 * ID : number. Each new cell will take the first available number so that numbers from deleted cells are re-used
40 41 * Type: number, corresponding to the cell type.
41 42 * In: [array of ID's to inbound Synapses and strength, e.g.: {ID:5,Strength:1.2},{ID:8,Strength:1.2}]
42 * Pos: {X, Y} vector, where 0,0 is the center of a creature which will ALWAYS be a braincell. (note that center of mass, as in the average position of all cells, will be used to determine direction for locomotors and such, not 0,0)
43 * Pos: {X, Y} vector, where 0,0 is the center of a creature which will ALWAYS be a Heart. (note that center of mass, as in the average position of all cells, will be used to determine direction for locomotors and such, not 0,0)
43 44 * }
44 45 *
45 46 * The output of a Cell is determined as follows:
46 47 * OUT = Sigmoid ( IN1Val*IN1Weight + IN2Val*IN2Weight + IN3Val*IN3Weight + ... )
47 48 * Sigmoid will accept numbers from negative infinity up until positive infinity, and as such the weights of all Synapses need not be clamped. Sigmoid will always output a value between zero and one.
49 *
50 * Note that any cells which would be disconnected from the heart should be automatically removed from the DNA string
48 51 */
49 52
50 53 function sigmoid(z)
@@ -9,7 +9,7 @@
9 * definitions:
9 * definitions:
10 * - cell: one out of many objects of uniform size that make up a creature
10 * - cell: one out of many objects of uniform size that make up a creature
11 * - sensor: a cell that is able to detect things
11 * - sensor: a cell that is able to detect things
12 * - activator: a cell that can respond to the signal of a Synapse
12 * - activator: a cell that can respond to the signal of a Synapse, using energy from Stomach cells. When no energy is available, the Activators are unable to do anything and as such the creature will essentially be 'dead'
13 * - Synapse: a connection between a sensor and an activator
13 * - Synapse: a connection between a sensor and an activator
14 * - braincell: a cell that acts as a hybrid activator/sensor. It receives inputs like an activator would, but instead of doing something on its own, it has outbound Synapse connections of its own to one or more sensors (or other brain cells)
14 * - braincell: a cell that acts as a hybrid activator/sensor. It receives inputs like an activator would, but instead of doing something on its own, it has outbound Synapse connections of its own to one or more sensors (or other brain cells)
15 *
15 *
@@ -30,6 +30,7 @@
30 * OTHER
30 * OTHER
31 * - Stomach: Can contain energy. Each cell/pellet eaten increases energy in any available Stomach cells. All Activators require an amount of energy from any of the available Stomach cells to function.
31 * - Stomach: Can contain energy. Each cell/pellet eaten increases energy in any available Stomach cells. All Activators require an amount of energy from any of the available Stomach cells to function.
32 * - Meat: A cell which does nothing except connect other cells. (and potentially function as armor)
32 * - Meat: A cell which does nothing except connect other cells. (and potentially function as armor)
33 * - Heart: Does nothing, but when the heart is destroyed the creature will die. Creature cannot have more than one Heart, which is always at 0,0
33 *
34 *
34 * A creature will multiply when all its Stomach cells are completely full, draining each of them by 50%. This spawns an Egg which will hatch into a copy of the parent creature with a slight mutation applied as soon as there is space available (read: the parent creature has moved suffficiently far away).
35 * A creature will multiply when all its Stomach cells are completely full, draining each of them by 50%. This spawns an Egg which will hatch into a copy of the parent creature with a slight mutation applied as soon as there is space available (read: the parent creature has moved suffficiently far away).
35 *
36 *
@@ -39,12 +40,14 @@
39 * ID : number. Each new cell will take the first available number so that numbers from deleted cells are re-used
40 * ID : number. Each new cell will take the first available number so that numbers from deleted cells are re-used
40 * Type: number, corresponding to the cell type.
41 * Type: number, corresponding to the cell type.
41 * In: [array of ID's to inbound Synapses and strength, e.g.: {ID:5,Strength:1.2},{ID:8,Strength:1.2}]
42 * In: [array of ID's to inbound Synapses and strength, e.g.: {ID:5,Strength:1.2},{ID:8,Strength:1.2}]
42 * Pos: {X, Y} vector, where 0,0 is the center of a creature which will ALWAYS be a braincell. (note that center of mass, as in the average position of all cells, will be used to determine direction for locomotors and such, not 0,0)
43 * Pos: {X, Y} vector, where 0,0 is the center of a creature which will ALWAYS be a Heart. (note that center of mass, as in the average position of all cells, will be used to determine direction for locomotors and such, not 0,0)
43 * }
44 * }
44 *
45 *
45 * The output of a Cell is determined as follows:
46 * The output of a Cell is determined as follows:
46 * OUT = Sigmoid ( IN1Val*IN1Weight + IN2Val*IN2Weight + IN3Val*IN3Weight + ... )
47 * OUT = Sigmoid ( IN1Val*IN1Weight + IN2Val*IN2Weight + IN3Val*IN3Weight + ... )
47 * Sigmoid will accept numbers from negative infinity up until positive infinity, and as such the weights of all Synapses need not be clamped. Sigmoid will always output a value between zero and one.
48 * Sigmoid will accept numbers from negative infinity up until positive infinity, and as such the weights of all Synapses need not be clamped. Sigmoid will always output a value between zero and one.
49 *
50 * Note that any cells which would be disconnected from the heart should be automatically removed from the DNA string
48 */
51 */
49
52
50 function sigmoid(z)
53 function sigmoid(z)