Le formiche riescono ad imparare a raggiungere il cibo
This commit is contained in:
parent
c3a22bb1a8
commit
bd7501b3d0
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"grid_size": 100,
|
"grid_size": 100,
|
||||||
"food": [11, 83],
|
"food": [61, 59],
|
||||||
"ants": [[10,52],[9,61],[9,63],[8,54],[9,78],[10,74],[10,58],[10,70],[10,73],[10,76],[40,77],[9,72],[9,70],[10,72],[10,75],[10,71],[9,75],[16,65],[10,63],[11,52]],
|
"ants": [[55,59,0.81],[33,64,0.81],[30,84,0.82],[21,90,0.89],[49,59,0.98],[37,59,0.85],[20,56,0.96],[54,57,0.81],[27,83,0.96],[33,24,0.83],[29,59,0.84],[22,59,0.94],[23,58,0.80],[26,90,0.81],[30,74,0.78],[33,60,0.89],[24,90,0.98],[52,59,0.90],[25,59,0.91],[26,73,0.83]],
|
||||||
"episode": 23320,
|
"episode": 415780,
|
||||||
"epsilon": 0.050
|
"epsilon": 0.050
|
||||||
}
|
}
|
||||||
|
|
@ -106,22 +106,15 @@
|
||||||
ctx.shadowBlur = 0;
|
ctx.shadowBlur = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 5. FORMICHE (Colorate in base alla velocità)
|
|
||||||
if (data.ants) {
|
if (data.ants) {
|
||||||
data.ants.forEach(ant => {
|
data.ants.forEach(ant => {
|
||||||
// ant[0] = x, ant[1] = y, ant[2] = speed
|
|
||||||
const ax = ant[0] * cellSize;
|
const ax = ant[0] * cellSize;
|
||||||
const ay = ant[1] * cellSize;
|
const ay = ant[1] * cellSize;
|
||||||
const speed = ant[2];
|
const speed = ant[2];
|
||||||
|
|
||||||
// Interpolazione Colore
|
|
||||||
// Speed 0.5 (Lenta) -> Blu (0, 0, 255)
|
|
||||||
// Speed 1.0 (Media) -> Arancio (255, 165, 0)
|
|
||||||
// Speed 2.5 (Veloce) -> Rosso Fuoco (255, 0, 0)
|
|
||||||
|
|
||||||
let color = "orange";
|
let color = "orange";
|
||||||
if (speed > 1.3) color = `rgb(255, ${255 - (speed*80)}, 0)`; // Diventa rossa
|
if (speed > 1.3) color = `rgb(255, ${255 - (speed*80)}, 0)`;
|
||||||
else if (speed < 0.9) color = `rgb(${speed*100}, ${speed*100}, 255)`; // Diventa blu
|
else if (speed < 0.9) color = `rgb(${speed*100}, ${speed*100}, 255)`;
|
||||||
|
|
||||||
ctx.fillStyle = color;
|
ctx.fillStyle = color;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue