Minor fixes
This commit is contained in:
parent
8817e5b090
commit
c26fd93087
6 changed files with 26 additions and 18 deletions
|
|
@ -28,7 +28,7 @@ export class GameRules {
|
||||||
nextGenerationCount: number;
|
nextGenerationCount: number;
|
||||||
} = {
|
} = {
|
||||||
currentGenerationCount: 0,
|
currentGenerationCount: 0,
|
||||||
nextGenerationCount: 0,
|
nextGenerationCount: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
public constructor(startingTimeInSeconds: number) {
|
public constructor(startingTimeInSeconds: number) {
|
||||||
|
|
@ -94,7 +94,9 @@ export class GameRules {
|
||||||
const currentGenerationCount =
|
const currentGenerationCount =
|
||||||
this.nextGenerationId % 2 === 1 ? evenGenerationCount : oddGenerationCount;
|
this.nextGenerationId % 2 === 1 ? evenGenerationCount : oddGenerationCount;
|
||||||
|
|
||||||
if (currentGenerationCount <= 100) {
|
const q = currentGenerationCount / settings.agentCount;
|
||||||
|
|
||||||
|
if (currentGenerationCount <= 100 && q < 0.05) {
|
||||||
this.nextGenerationId++;
|
this.nextGenerationId++;
|
||||||
this.lastGenerationChangeTimeInSeconds = performance.now() / 1000;
|
this.lastGenerationChangeTimeInSeconds = performance.now() / 1000;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,11 @@ export const setUpSettingsPage = (
|
||||||
min: 1,
|
min: 1,
|
||||||
max: 30,
|
max: 30,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
new SettingsSlider(settings, 'clarity', {
|
||||||
|
min: 0.00001,
|
||||||
|
max: 1,
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
const sliderContainerElement = document.createElement('div');
|
const sliderContainerElement = document.createElement('div');
|
||||||
|
|
|
||||||
|
|
@ -112,10 +112,10 @@ fn main(
|
||||||
// trailBelow.g = settings.isNextGenerationOdd * (trailBelow.r + trailBelow.g);
|
// trailBelow.g = settings.isNextGenerationOdd * (trailBelow.r + trailBelow.g);
|
||||||
} else {
|
} else {
|
||||||
let relativeWeight = mix(trailBelow.g - trailBelow.r, trailBelow.r - trailBelow.g, isFromOddGeneration);
|
let relativeWeight = mix(trailBelow.g - trailBelow.r, trailBelow.r - trailBelow.g, isFromOddGeneration);
|
||||||
if relativeWeight > 0 && (
|
if (relativeWeight > 0 && (
|
||||||
(isFromCurrentGeneration == 1.0 && trailBelow.a == 0 && random.b < settings.infectionProbability)
|
(isFromCurrentGeneration == 1.0 && trailBelow.a == 0 && random.b < settings.infectionProbability)
|
||||||
|| (isFromCurrentGeneration == 0.0 && trailBelow.a > 0)
|
|| (isFromCurrentGeneration == 0.0 && trailBelow.a > 0)
|
||||||
) {
|
)) || (trailBelow.a > 0 && isFromCurrentGeneration == 0.0){
|
||||||
// trailBelow.r = isFromOddGeneration * (trailBelow.r + trailBelow.g);
|
// trailBelow.r = isFromOddGeneration * (trailBelow.r + trailBelow.g);
|
||||||
// trailBelow.g = (1 - isFromOddGeneration) * (trailBelow.r + trailBelow.g);
|
// trailBelow.g = (1 - isFromOddGeneration) * (trailBelow.r + trailBelow.g);
|
||||||
agent.generation = (agent.generation + 1) % 2;
|
agent.generation = (agent.generation + 1) % 2;
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ fn fragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
||||||
) / 8;
|
) / 8;
|
||||||
|
|
||||||
let decayed = clamp(vec4(
|
let decayed = clamp(vec4(
|
||||||
clamp(current.rgb + (current.rgb - 1.001) * settings.decayRateTrails, vec3(0), vec3(1)),
|
current.rgb * settings.decayRateTrails,
|
||||||
max(0, current.a + (current.a - 1.001) * settings.decayRateBrush)
|
max(0, current.a + (current.a - 1.001) * settings.decayRateBrush)
|
||||||
), vec4(0), vec4(1));
|
), vec4(0), vec4(1));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,8 @@ fn fragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
||||||
oddGenerationStrength * settings.oddGenerationColor,
|
oddGenerationStrength * settings.oddGenerationColor,
|
||||||
oddGenerationStrength / (evenGenerationStrength + oddGenerationStrength + 0.000001)
|
oddGenerationStrength / (evenGenerationStrength + oddGenerationStrength + 0.000001)
|
||||||
),
|
),
|
||||||
brushStrength * settings.brushColor);
|
brushStrength * settings.brushColor
|
||||||
|
);
|
||||||
|
|
||||||
let strength = max(evenGenerationStrength, max(oddGenerationStrength, brushStrength));
|
let strength = max(evenGenerationStrength, max(oddGenerationStrength, brushStrength));
|
||||||
|
|
||||||
|
|
@ -34,5 +35,5 @@ fn fragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clarity(strength: f32) -> f32 {
|
fn clarity(strength: f32) -> f32 {
|
||||||
return sign(strength);
|
return pow(strength, settings.clarity);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,22 +15,22 @@ const initialValues: GameLoopSettings &
|
||||||
currentGenerationAggression: -5,
|
currentGenerationAggression: -5,
|
||||||
nextGenerationAggression: 0.2,
|
nextGenerationAggression: 0.2,
|
||||||
|
|
||||||
moveSpeed: 90,
|
moveSpeed: 74,
|
||||||
turnSpeed: 53,
|
turnSpeed: 45,
|
||||||
sensorOffsetAngle: 40,
|
sensorOffsetAngle: 31,
|
||||||
sensorOffsetDistance: 43,
|
sensorOffsetDistance: 43,
|
||||||
turnWhenLost: 0.08,
|
turnWhenLost: 0.01,
|
||||||
|
|
||||||
brushTrailWeight: 500,
|
brushTrailWeight: 500,
|
||||||
individualTrailWeight: 0.78,
|
individualTrailWeight: 0.05,
|
||||||
|
|
||||||
diffusionRateTrails: 1.11,
|
diffusionRateTrails: 0,
|
||||||
decayRateTrails: 718,
|
decayRateTrails: 944,
|
||||||
diffusionRateBrush: 0.25,
|
diffusionRateBrush: 0.35,
|
||||||
decayRateBrush: 15,
|
decayRateBrush: 18,
|
||||||
|
|
||||||
clarity: 0,
|
clarity: 0.7,
|
||||||
brushSize: 16,
|
brushSize: 12,
|
||||||
|
|
||||||
brushSizeVariation: 0.5, // hidden on the UI
|
brushSizeVariation: 0.5, // hidden on the UI
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue