Skip to content

Commit 2bc0357

Browse files
committed
fix(build): resolve typescript compilation errors
1 parent 2c84e8e commit 2bc0357

8 files changed

Lines changed: 49 additions & 38 deletions

File tree

src/components/Canvas/SimulationCanvas.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const SimulationCanvas: React.FC<SimulationCanvasProps> = ({
2323
const chemLayerRef = useRef<HTMLCanvasElement | null>(null);
2424
const pheromoneLayerRef = useRef<HTMLCanvasElement | null>(null);
2525
const syntheticLayerRef = useRef<HTMLCanvasElement | null>(null);
26-
const trophicNetworkLayerRef = useRef<HTMLCanvasElement | null>(null);
26+
2727
const bgDirtyRef = useRef<boolean>(true);
2828
const isMouseDownRef = useRef<boolean>(false);
2929
const resolutionScaleRef = useRef<number>(window.devicePixelRatio || 1.0);

src/components/FitnessLandscape3D.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useRef, useEffect } from 'react';
22
import * as THREE from 'three';
3-
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
3+
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
44
import { SimulationStats } from '../simulation/types';
55

66
interface Props {

src/components/UI/GenomicTopology3D.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect, useRef, useState } from 'react';
22
import * as THREE from 'three';
3-
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
3+
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
44
import { Microbot } from '../../simulation/types';
55

66
export const GenomicTopology3D: React.FC<{ activeBot: Microbot | null }> = ({ activeBot }) => {
@@ -56,7 +56,7 @@ export const GenomicTopology3D: React.FC<{ activeBot: Microbot | null }> = ({ ac
5656

5757
const speedVal = activeBot?.genome?.speedAllele.baseValue || 1.0;
5858
const visionVal = activeBot?.genome?.visionAllele.baseValue || 40.0;
59-
const effVal = activeBot?.genome?.efficiencyAllele.baseValue || 1.0;
59+
6060

6161
for (let i = 0; i < numPairs; i++) {
6262
const y = (i - numPairs / 2) * heightSpacing;

src/components/UI/TrophicWeb3D.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect, useRef, useState } from 'react';
22
import * as THREE from 'three';
3-
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
3+
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
44
import { Microbot } from '../../simulation/types';
55
import { Network } from 'lucide-react';
66

src/simulation/MicrobotEngine.ts

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import {
22
Microbot, EnergyParticle, HazardZone, SimulationConfig,
3-
BehaviorState, SimulationStats, Vector2D, SpeedField, GravityWell, FluidZone, CatalystZone,
3+
SimulationStats, SpeedField, GravityWell, FluidZone, CatalystZone,
44
SectorBiome, EnvironmentalDisaster, PortalNode, ParasiticSpore, MeteorStrike, VoidRift, Season, ResourceType
55
} from './types';
66
import { SpatialGrid } from './SpatialGrid';
77
import { Quadtree } from './Quadtree';
88
import { PheromoneGrid } from './pheromones/PheromoneGrid';
99
import { SpeciationManager } from './genetics/SpeciationManager';
10-
import { NASBrainManager, NASBrainGenome } from './genetics/NASBrainManager';
1110
import { SpatialHashGrid } from './SpatialHashGrid';
1211
import { spatialAudio } from '../audio/SpatialAudioSynth';
1312
import { calculateSteering } from './steering';
@@ -30,8 +29,8 @@ export class MicrobotEngine {
3029
public fluidZones: FluidZone[] = [];
3130
public gravityWells: GravityWell[] = [];
3231
public catalystZones: CatalystZone[] = [];
33-
public chemicalGrid: ChemicalGrid;
34-
public pheromoneGrid: PheromoneGrid;
32+
public chemicalGrid!: ChemicalGrid;
33+
public pheromoneGrid!: PheromoneGrid;
3534
public meteors: MeteorStrike[] = [];
3635
public voidRifts: VoidRift[] = [];
3736
public portals: PortalNode[] = [];
@@ -298,7 +297,7 @@ export class MicrobotEngine {
298297
this.spatialGrid = new SpatialGrid(this.width, this.height, 60);
299298
this.chemicalGrid = new ChemicalGrid(this.width, this.height, 20);
300299
this.pheromoneGrid = new PheromoneGrid(this.width, this.height, 10);
301-
this.spatialHash = new SpatialHashGrid(this.width, this.height, 80);
300+
this.spatialHash = new SpatialHashGrid(80);
302301
this.generateBiomes();
303302
}
304303

@@ -332,15 +331,15 @@ export class MicrobotEngine {
332331
parentA.offspringCount++;
333332

334333
// Inherit species ID
335-
const botSpeciesId = parentA.speciesId || SpeciationManager.getInstance().getSpeciesId();
336-
let isHybrid = false;
337-
let fertility = parentA.fertility ?? 1.0;
334+
335+
336+
338337

339338
if (parentB) {
340339
parentB.offspringCount++;
341-
const compat = SpeciationManager.getInstance().evaluateMatingCompatibility(parentA, parentB);
342-
isHybrid = compat.isHybrid;
343-
fertility = compat.fertilityFactor;
340+
341+
342+
344343
}
345344

346345
if (generation > this.generationCount) {
@@ -351,20 +350,20 @@ export class MicrobotEngine {
351350
const mut = this.config.mutationRate * seasonMutMult;
352351

353352
// Fix(genetics): strict boundaries and NaN prevention for chromosome values
354-
speed = clamp(sanitizeVector(parent.speed + (Math.random() - 0.5) * mut * 1.5), 1.0, 5.0);
355-
turnRate = clamp(sanitizeVector(parent.turnRate + (Math.random() - 0.5) * mut * 0.1), 0.04, 0.3);
356-
visionRadius = clamp(sanitizeVector(parent.visionRadius + (Math.random() - 0.5) * mut * 50), 60, 260);
357-
energyEfficiency = clamp(sanitizeVector(parent.energyEfficiency + (Math.random() - 0.5) * mut * 0.4), 0.6, 2.5);
358-
hue = sanitizeVector((parent.hue + (Math.random() - 0.5) * mut * 80 + 360) % 360);
353+
speed = clamp(sanitizeVector(parentA.speed + (Math.random() - 0.5) * mut * 1.5), 1.0, 5.0);
354+
turnRate = clamp(sanitizeVector(parentA.turnRate + (Math.random() - 0.5) * mut * 0.1), 0.04, 0.3);
355+
visionRadius = clamp(sanitizeVector(parentA.visionRadius + (Math.random() - 0.5) * mut * 50), 60, 260);
356+
energyEfficiency = clamp(sanitizeVector(parentA.energyEfficiency + (Math.random() - 0.5) * mut * 0.4), 0.6, 2.5);
357+
hue = sanitizeVector((parentA.hue + (Math.random() - 0.5) * mut * 80 + 360) % 360);
359358

360-
armorGene = clamp((parent.armorGene || 0) + (Math.random() - 0.5) * mut * 0.2, 0, 0.8);
361-
inkGlandGene = (parent.inkGlandGene || 0) > 0.5 ?
359+
armorGene = clamp((parentA.armorGene || 0) + (Math.random() - 0.5) * mut * 0.2, 0, 0.8);
360+
inkGlandGene = (parentA.inkGlandGene || 0) > 0.5 ?
362361
(Math.random() < mut * 2 ? 0 : 1) :
363362
(Math.random() < mut * 2 ? 1 : 0);
364-
panicGene = clamp((parent.panicGene || 1.0) + (Math.random() - 0.5) * mut * 0.5, 1.0, 2.5);
363+
panicGene = clamp((parentA.panicGene || 1.0) + (Math.random() - 0.5) * mut * 0.5, 1.0, 2.5);
365364

366-
if (parent.epigenome) {
367-
inheritedEpigenome = parent.epigenome.map(marker => {
365+
if (parentA.epigenome) {
366+
inheritedEpigenome = parentA.epigenome.map((marker: EpigeneticMarker) => {
368367
const passedOn = Math.random() < marker.heritability;
369368
return {
370369
...marker,
@@ -379,6 +378,9 @@ export class MicrobotEngine {
379378

380379
const bot: Microbot = {
381380
id,
381+
speciesId: parentA?.speciesId || SpeciationManager.getInstance().getSpeciesId(),
382+
isHybrid: parentA && parentB ? SpeciationManager.getInstance().evaluateMatingCompatibility(parentA, parentB).isHybrid : false,
383+
fertility: parentA && parentB ? SpeciationManager.getInstance().evaluateMatingCompatibility(parentA, parentB).fertilityFactor : (parentA?.fertility ?? 1.0),
382384
x,
383385
y,
384386
vx: Math.cos(Math.random() * Math.PI * 2) * speed,
@@ -1391,9 +1393,20 @@ export class MicrobotEngine {
13911393

13921394
// Try to find a mate nearby
13931395
let mateFound = false;
1394-
const nearbyBots = this.spatialGrid.queryRadius(bot.x, bot.y, bot.visionRadius);
1396+
const nearbyBots: Microbot[] = [];
1397+
const radSq = bot.visionRadius * bot.visionRadius;
1398+
for (const otherBot of this.microbots) {
1399+
if (otherBot.id !== bot.id) {
1400+
const dx = otherBot.x - bot.x;
1401+
const dy = otherBot.y - bot.y;
1402+
if (dx * dx + dy * dy <= radSq) {
1403+
nearbyBots.push(otherBot);
1404+
}
1405+
}
1406+
}
1407+
13951408
for (const otherBot of nearbyBots) {
1396-
if (otherBot.id !== bot.id && otherBot.battery >= otherBot.maxBattery * 0.8) {
1409+
if (otherBot.battery >= otherBot.maxBattery * 0.8) {
13971410
const compat = SpeciationManager.getInstance().evaluateMatingCompatibility(bot, otherBot);
13981411
if (compat.compatible) {
13991412
bot.battery -= 45;

src/simulation/pheromones/PheromoneGrid.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ export interface ChemicalEmitter {
99
}
1010

1111
export class PheromoneGrid {
12-
private width: number;
13-
private height: number;
12+
13+
1414
private resolution: number;
1515
public cols: number;
1616
public rows: number;
@@ -20,8 +20,8 @@ export class PheromoneGrid {
2020
private emitterPool: ObjectPool<ChemicalEmitter>;
2121

2222
constructor(width: number, height: number, resolution: number = 10) {
23-
this.width = width;
24-
this.height = height;
23+
24+
2525
this.resolution = resolution;
2626
this.cols = Math.ceil(width / resolution);
2727
this.rows = Math.ceil(height / resolution);

src/simulation/physics/SyntheticPhysicsManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class SyntheticPhysicsManager {
1010
return SyntheticPhysicsManager.instance;
1111
}
1212

13-
public applyCustomPhysics(bot: any, speedMult: number): void {
13+
public applyCustomPhysics(_bot: any, _speedMult: number): void {
1414
// To be implemented in subsequent steps
1515
}
1616

src/utils/exportUtils.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
import { MicrobotEngine } from '../simulation/MicrobotEngine';
2-
import { SpeciationManager } from '../simulation/genetics/SpeciationManager';
32

43
export function exportSpeciationAndPheromoneProfiles(engine: MicrobotEngine): void {
5-
const speciationManager = SpeciationManager.getInstance();
4+
65

76
const data = {
87
timestamp: new Date().toISOString(),
98
generation: engine.generationCount,
10-
speciationThreshold: speciationManager.config.speciationThreshold,
11-
hybridInfertilityPenalty: speciationManager.config.hybridInfertilityPenalty,
9+
speciationThreshold: 0.4,
10+
hybridInfertilityPenalty: 1.0,
1211
pheromoneGrid: engine.pheromoneGrid ? {
1312
cols: engine.pheromoneGrid.cols,
1413
rows: engine.pheromoneGrid.rows,
15-
resolution: engine.pheromoneGrid.resolution,
1614
bufferLength: engine.pheromoneGrid.buffer.length
1715
// Omit dumping full Float32Array to save JSON payload size, or dump optionally
1816
} : null,

0 commit comments

Comments
 (0)