carCanvas.height=window.innerHeight; carCanvas.width=200; networkCanvas.height=window.innerHeight; networkCanvas.width=298; const carCtx=carCanvas.getContext("2d"); const networkCtx=networkCanvas.getContext("2d"); const road=new Road(carCanvas.width/2,carCanvas.width*0.9); const N=100; const cars=generateCars(N); const traffic=[ new Car(100,-100,30,50,"DUMMY",2) ]; let bestCar=cars[0]; if(localStorage.getItem("bestBrain")){ for(let i=0;i0){ NeuralNetwork.mutate(cars[i].brain,0.2); } } } animate(); function animate(){ for(let i=0;ic.y==Math.min( ...cars.map(c=>c.y) )); carCanvas.height=window.innerHeight; networkCanvas.height=window.innerHeight; carCtx.translate(0,-bestCar.y+carCanvas.height*0.7); road.draw(carCtx); for(let i=0;i