Rename species to generation
This commit is contained in:
parent
3414f38c3a
commit
f3f2547724
10 changed files with 31 additions and 31 deletions
|
|
@ -13,7 +13,7 @@ fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
|
|||
return;
|
||||
}
|
||||
|
||||
if agents[id].species % 2 == 0 {
|
||||
if agents[id].generation % 2 == 0 {
|
||||
atomicAdd(&counters.evenGenerationAlive, 1);
|
||||
} else {
|
||||
atomicAdd(&counters.oddGenerationAlive, 1);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@ fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
|
|||
}
|
||||
|
||||
if length(settings.center - agents[id].position) < settings.radius {
|
||||
agents[id].species = settings.nextGenerationId;
|
||||
agents[id].generation = settings.nextGenerationId;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
struct Agent {
|
||||
position: vec2<f32>,
|
||||
angle: f32,
|
||||
species: f32,
|
||||
generation: f32,
|
||||
}
|
||||
|
||||
@group(1) @binding(1) var<storage, read_write> agents: array<Agent>;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { vec2 } from 'gl-matrix';
|
|||
export interface Agent {
|
||||
position: vec2;
|
||||
angle: number;
|
||||
species: number;
|
||||
generation: number;
|
||||
}
|
||||
|
||||
export const AGENT_SIZE_IN_BYTES = 4 * Float32Array.BYTES_PER_ELEMENT;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
|
|||
// even generation id -> red channel
|
||||
// odd generation id -> green channel
|
||||
|
||||
let isFromEvenGeneration = agent.species % 2 == 0;
|
||||
let isFromEvenGeneration = agent.generation % 2 == 0;
|
||||
|
||||
let trailForward = sense(agent.position, agent.angle, settings.sensorOffset, 0);
|
||||
let trailLeft = sense(agent.position, agent.angle, settings.sensorOffset, settings.sensorAngle);
|
||||
|
|
@ -81,18 +81,18 @@ fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
|
|||
|
||||
if(isFromEvenGeneration) {
|
||||
if next.r < next.g {
|
||||
if agent.species == settings.nextGenerationId {
|
||||
// agent.species -= 1;
|
||||
if agent.generation == settings.nextGenerationId {
|
||||
// agent.generation -= 1;
|
||||
} else {
|
||||
agent.species += 1;
|
||||
agent.generation += 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if next.g < next.r {
|
||||
if agent.species == settings.nextGenerationId {
|
||||
// agent.species -= 1;
|
||||
if agent.generation == settings.nextGenerationId {
|
||||
// agent.generation -= 1;
|
||||
} else {
|
||||
agent.species += 1;
|
||||
agent.generation += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue