Difference between revisions of "Main Page"
| Line 16: | Line 16: | ||
I live in continuous [[Daniele_Grosso:Interesting_courses|learning]] mode: here some usefull (to me) stuff: [[Daniele_Grosso_notebooks|notes]], [[Daniele_Grosso_howto|howto]], [[Daniele_Grosso_links|links]], [[Daniele_Grosso_web links|web links]], [[Daniele_Grosso_lists|lists]] and [[Daniele_Grosso_software|software]] sections. | I live in continuous [[Daniele_Grosso:Interesting_courses|learning]] mode: here some usefull (to me) stuff: [[Daniele_Grosso_notebooks|notes]], [[Daniele_Grosso_howto|howto]], [[Daniele_Grosso_links|links]], [[Daniele_Grosso_web links|web links]], [[Daniele_Grosso_lists|lists]] and [[Daniele_Grosso_software|software]] sections. | ||
| + | |||
| + | |||
| + | DAISY WORLD | ||
| + | |||
| + | |||
| + | |||
| + | GAME OF LIFE | ||
| + | |||
| + | ---- | ||
| + | // CONWAY'S GAME OF LIFE - Stessa identica logica del Daisyworld | ||
| + | // Nessuna libreria esterna - copia e incolla e funziona subito! | ||
| + | |||
| + | int celle = 80; | ||
| + | float cellSize; | ||
| + | |||
| + | int[][] griglia; // 0 = morta, 1 = viva | ||
| + | int[][] nuovaGriglia; | ||
| + | |||
| + | boolean pausa = false; // premi P per mettere in pausa/riprendere | ||
| + | float velocita = 10; // frame al secondo (premi +/- per cambiare velocità) | ||
| + | |||
| + | void setup() { | ||
| + | size(800, 600); | ||
| + | cellSize = width / float(celle); | ||
| + | |||
| + | griglia = new int[celle][celle]; | ||
| + | nuovaGriglia = new int[celle][celle]; | ||
| + | |||
| + | // Configurazione casuale iniziale (30% di celle vive) | ||
| + | randomSeed(42); | ||
| + | for (int x = 0; x < celle; x++) { | ||
| + | for (int y = 0; y < celle; y++) { | ||
| + | griglia[x][y] = random(1) < 0.3 ? 1 : 0; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | frameRate(velocita); | ||
| + | } | ||
| + | |||
| + | void draw() { | ||
| + | background(20); | ||
| + | |||
| + | if (!pausa) { | ||
| + | aggiornaGameOfLife(); | ||
| + | } | ||
| + | |||
| + | // DISEGNA LA GRIGLIA | ||
| + | noStroke(); | ||
| + | for (int x = 0; x < celle; x++) { | ||
| + | for (int y = 0; y < celle; y++) { | ||
| + | if (griglia[x][y] == 1) { | ||
| + | fill(0, 255, 100); // verde neon per celle vive | ||
| + | } else { | ||
| + | fill(40); // grigio scuro per morte | ||
| + | } | ||
| + | rect(x*cellSize, y*cellSize, cellSize, cellSize); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | // Bordini leggeri per vedere meglio le celle | ||
| + | stroke(50); | ||
| + | noFill(); | ||
| + | for (int x = 0; x <= celle; x++) { | ||
| + | line(x*cellSize, 0, x*cellSize, height); | ||
| + | } | ||
| + | for (int y = 0; y <= celle; y++) { | ||
| + | line(0, y*cellSize, width, y*cellSize); | ||
| + | } | ||
| + | noStroke(); | ||
| + | |||
| + | // INFO A SCHERMO | ||
| + | fill(255); | ||
| + | textSize(16); | ||
| + | textAlign(LEFT); | ||
| + | int y = 30; | ||
| + | text("GAME OF LIFE", 15, y+=25); | ||
| + | text("Celle vive: " + contaVive(), 15, y+=30); | ||
| + | text("Generazione: " + frameCount, 15, y+=25); | ||
| + | text("Velocità: " + nf(velocita,1,1) + " fps [+] [-]", 15, y+=30); | ||
| + | text("Pausa: " + (pausa ? "SÌ [P]" : "NO [P]"), 15, y+=30); | ||
| + | text("R = casuale C = pulisci G = glider gun SPAZIO = reset casuale", 15, y+=35); | ||
| + | text("Clic sinistro = disegna Clic destro/tasto = cancella", 15, y+=25); | ||
| + | } | ||
| + | |||
| + | // ------------------------------------------------------------------ | ||
| + | void aggiornaGameOfLife() { | ||
| + | // Regole classiche di Conway | ||
| + | for (int x = 0; x < celle; x++) { | ||
| + | for (int y = 0; y < celle; y++) { | ||
| + | int vicini = contaVicini(x, y); | ||
| + | |||
| + | if (griglia[x][y] == 1) { | ||
| + | // Sopravvive solo con 2 o 3 vicini | ||
| + | nuovaGriglia[x][y] = (vicini == 2 || vicini == 3) ? 1 : 0; | ||
| + | } else { | ||
| + | // Nasce solo con esattamente 3 vicini | ||
| + | nuovaGriglia[x][y] = (vicini == 3) ? 1 : 0; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | // Scambia le griglie | ||
| + | int[][] temp = griglia; | ||
| + | griglia = nuovaGriglia; | ||
| + | nuovaGriglia = temp; | ||
| + | } | ||
| + | |||
| + | int contaVicini(int x, int y) { | ||
| + | int conta = 0; | ||
| + | for (int dx = -1; dx <= 1; dx++) { | ||
| + | for (int dy = -1; dy <= 1; dy++) { | ||
| + | if (dx == 0 && dy == 0) continue; | ||
| + | int nx = (x + dx + celle) % celle; | ||
| + | int ny = (y + dy + celle) % celle; | ||
| + | if (griglia[nx][ny] == 1) conta++; | ||
| + | } | ||
| + | } | ||
| + | return conta; | ||
| + | } | ||
| + | |||
| + | int contaVive() { | ||
| + | int c = 0; | ||
| + | for (int x = 0; x < celle; x++) | ||
| + | for (int y = 0; y < celle; y++) | ||
| + | if (griglia[x][y] == 1) c++; | ||
| + | return c; | ||
| + | } | ||
| + | |||
| + | // ------------------------------------------------------------------ | ||
| + | // COMANDI TASTIERA (uguali al Daisyworld!) | ||
| + | void keyPressed() { | ||
| + | if (key == ' ') { | ||
| + | // Reset casuale | ||
| + | for (int x = 0; x < celle; x++) | ||
| + | for (int y = 0; y < celle; y++) | ||
| + | griglia[x][y] = random(1) < 0.3 ? 1 : 0; | ||
| + | } | ||
| + | |||
| + | if (key == 'r' || key == 'R') { // Random | ||
| + | for (int x = 0; x < celle; x++) | ||
| + | for (int y = 0; y < celle; y++) | ||
| + | griglia[x][y] = random(1) < 0.25 ? 1 : 0; | ||
| + | } | ||
| + | |||
| + | if (key == 'c' || key == 'C') { // Pulisci tutto | ||
| + | for (int x = 0; x < celle; x++) | ||
| + | for (int y = 0; y < celle; y++) | ||
| + | griglia[x][y] = 0; | ||
| + | } | ||
| + | |||
| + | if (key == 'g' || key == 'G') { // Glider Gun di Gosper! | ||
| + | pulisci(); | ||
| + | gliderGun(); | ||
| + | } | ||
| + | |||
| + | if (key == 'p' || key == 'P') { | ||
| + | pausa = !pausa; | ||
| + | } | ||
| + | |||
| + | if (key == '+' || key == '=') { | ||
| + | velocita = min(60, velocita + 2); | ||
| + | frameRate(velocita); | ||
| + | } | ||
| + | if (key == '-' || key == '_') { | ||
| + | velocita = max(1, velocita - 2); | ||
| + | frameRate(velocita); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | // Disegno a mano con il mouse | ||
| + | void mousePressed() { | ||
| + | int x = floor(mouseX / cellSize); | ||
| + | int y = floor(mouseY / cellSize); | ||
| + | if (x >= 0 && x < celle && y >= 0 && y < celle) { | ||
| + | if (mouseButton == LEFT) griglia[x][y] = 1; | ||
| + | if (mouseButton == RIGHT) griglia[x][y] = 0; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | void mouseDragged() { | ||
| + | mousePressed(); // permette di disegnare tenendo premuto | ||
| + | } | ||
| + | |||
| + | // Configurazioni famose | ||
| + | void gliderGun() { | ||
| + | // Gosper Glider Gun (funziona perfettamente!) | ||
| + | int[][] gun = { | ||
| + | {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0}, | ||
| + | {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0}, | ||
| + | {0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1}, | ||
| + | {0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1}, | ||
| + | {1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0}, | ||
| + | {1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0}, | ||
| + | {0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0}, | ||
| + | {0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, | ||
| + | {0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} | ||
| + | }; | ||
| + | |||
| + | pulisci(); | ||
| + | for (int x = 0; x < gun.length; x++) { | ||
| + | for (int y = 0; y < gun[0].length; y++) { | ||
| + | if (x < celle && y < celle) | ||
| + | griglia[x+10][y+10] = gun[y][x]; // ruotato per entrare bene | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | void pulisci() { | ||
| + | for (int x = 0; x < celle; x++) | ||
| + | for (int y = 0; y < celle; y++) | ||
| + | griglia[x][y] = 0; | ||
| + | } | ||
| + | |||
| + | |||
I am intereseted/involved in the following [[Daniele_Grosso_calls|'''calls''']], [[Daniele_Grosso_projects|projects]], [[Daniele_Grosso_proposals|proposals]] ([[dashboard]]) with [[with_AISTAP|AISTAP]], [[with_AIF|AIF]]. | I am intereseted/involved in the following [[Daniele_Grosso_calls|'''calls''']], [[Daniele_Grosso_projects|projects]], [[Daniele_Grosso_proposals|proposals]] ([[dashboard]]) with [[with_AISTAP|AISTAP]], [[with_AIF|AIF]]. | ||
Revision as of 17:15, 21 November 2025
Welcome to my website!
I am a physicst. I work at the Department of Physics, University of Genoa.
INFN associate (INFN section of Genoa). Member of AIF and SIF, EPS and IEEE. Also member of [AI] Also active member of AISTAP and WCGTC.
An overview of my training and former positions can be found in brief biography and/or CV.
My main interests are in Research and Development, Didactics (Teachings) and the Societal impact of Research and Didactics.
Areas of interests are mainly (but not only): medical physics, imaging, statistics, data analysis, computational physics, physical computing, astrophysics, nuclear physics, robotics, vision, ML, AI
Information on my activities can be found here: projects, publications, teachings.
I live in continuous learning mode: here some usefull (to me) stuff: notes, howto, links, web links, lists and software sections.
DAISY WORLD
GAME OF LIFE
// CONWAY'S GAME OF LIFE - Stessa identica logica del Daisyworld // Nessuna libreria esterna - copia e incolla e funziona subito!
int celle = 80; float cellSize;
int[][] griglia; // 0 = morta, 1 = viva int[][] nuovaGriglia;
boolean pausa = false; // premi P per mettere in pausa/riprendere float velocita = 10; // frame al secondo (premi +/- per cambiare velocità)
void setup() {
size(800, 600);
cellSize = width / float(celle);
griglia = new int[celle][celle];
nuovaGriglia = new int[celle][celle];
// Configurazione casuale iniziale (30% di celle vive)
randomSeed(42);
for (int x = 0; x < celle; x++) {
for (int y = 0; y < celle; y++) {
griglia[x][y] = random(1) < 0.3 ? 1 : 0;
}
}
frameRate(velocita);
}
void draw() {
background(20);
if (!pausa) {
aggiornaGameOfLife();
}
// DISEGNA LA GRIGLIA
noStroke();
for (int x = 0; x < celle; x++) {
for (int y = 0; y < celle; y++) {
if (griglia[x][y] == 1) {
fill(0, 255, 100); // verde neon per celle vive
} else {
fill(40); // grigio scuro per morte
}
rect(x*cellSize, y*cellSize, cellSize, cellSize);
}
}
// Bordini leggeri per vedere meglio le celle
stroke(50);
noFill();
for (int x = 0; x <= celle; x++) {
line(x*cellSize, 0, x*cellSize, height);
}
for (int y = 0; y <= celle; y++) {
line(0, y*cellSize, width, y*cellSize);
}
noStroke();
// INFO A SCHERMO
fill(255);
textSize(16);
textAlign(LEFT);
int y = 30;
text("GAME OF LIFE", 15, y+=25);
text("Celle vive: " + contaVive(), 15, y+=30);
text("Generazione: " + frameCount, 15, y+=25);
text("Velocità: " + nf(velocita,1,1) + " fps [+] [-]", 15, y+=30);
text("Pausa: " + (pausa ? "SÌ [P]" : "NO [P]"), 15, y+=30);
text("R = casuale C = pulisci G = glider gun SPAZIO = reset casuale", 15, y+=35);
text("Clic sinistro = disegna Clic destro/tasto = cancella", 15, y+=25);
}
// ------------------------------------------------------------------ void aggiornaGameOfLife() {
// Regole classiche di Conway
for (int x = 0; x < celle; x++) {
for (int y = 0; y < celle; y++) {
int vicini = contaVicini(x, y);
if (griglia[x][y] == 1) {
// Sopravvive solo con 2 o 3 vicini
nuovaGriglia[x][y] = (vicini == 2 || vicini == 3) ? 1 : 0;
} else {
// Nasce solo con esattamente 3 vicini
nuovaGriglia[x][y] = (vicini == 3) ? 1 : 0;
}
}
}
// Scambia le griglie
int[][] temp = griglia;
griglia = nuovaGriglia;
nuovaGriglia = temp;
}
int contaVicini(int x, int y) {
int conta = 0;
for (int dx = -1; dx <= 1; dx++) {
for (int dy = -1; dy <= 1; dy++) {
if (dx == 0 && dy == 0) continue;
int nx = (x + dx + celle) % celle;
int ny = (y + dy + celle) % celle;
if (griglia[nx][ny] == 1) conta++;
}
}
return conta;
}
int contaVive() {
int c = 0;
for (int x = 0; x < celle; x++)
for (int y = 0; y < celle; y++)
if (griglia[x][y] == 1) c++;
return c;
}
// ------------------------------------------------------------------ // COMANDI TASTIERA (uguali al Daisyworld!) void keyPressed() {
if (key == ' ') {
// Reset casuale
for (int x = 0; x < celle; x++)
for (int y = 0; y < celle; y++)
griglia[x][y] = random(1) < 0.3 ? 1 : 0;
}
if (key == 'r' || key == 'R') { // Random
for (int x = 0; x < celle; x++)
for (int y = 0; y < celle; y++)
griglia[x][y] = random(1) < 0.25 ? 1 : 0;
}
if (key == 'c' || key == 'C') { // Pulisci tutto
for (int x = 0; x < celle; x++)
for (int y = 0; y < celle; y++)
griglia[x][y] = 0;
}
if (key == 'g' || key == 'G') { // Glider Gun di Gosper!
pulisci();
gliderGun();
}
if (key == 'p' || key == 'P') {
pausa = !pausa;
}
if (key == '+' || key == '=') {
velocita = min(60, velocita + 2);
frameRate(velocita);
}
if (key == '-' || key == '_') {
velocita = max(1, velocita - 2);
frameRate(velocita);
}
}
// Disegno a mano con il mouse void mousePressed() {
int x = floor(mouseX / cellSize);
int y = floor(mouseY / cellSize);
if (x >= 0 && x < celle && y >= 0 && y < celle) {
if (mouseButton == LEFT) griglia[x][y] = 1;
if (mouseButton == RIGHT) griglia[x][y] = 0;
}
}
void mouseDragged() {
mousePressed(); // permette di disegnare tenendo premuto
}
// Configurazioni famose void gliderGun() {
// Gosper Glider Gun (funziona perfettamente!)
int[][] gun = {
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1},
{0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1},
{1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0},
{1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,1,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
};
pulisci();
for (int x = 0; x < gun.length; x++) {
for (int y = 0; y < gun[0].length; y++) {
if (x < celle && y < celle)
griglia[x+10][y+10] = gun[y][x]; // ruotato per entrare bene
}
}
}
void pulisci() {
for (int x = 0; x < celle; x++)
for (int y = 0; y < celle; y++)
griglia[x][y] = 0;
}
I am intereseted/involved in the following calls, projects, proposals (dashboard) with AISTAP, AIF.
You may contact me at the following address:
Daniele Grosso (Ph.D) LTD LAB (Low Temperature Detectors LAB) DIFI (Department of Physics, University of genoa) INFN (INFN section of Genoa) v. Dodecaneso 33, 16146 Genova (GE) - IT Tel. +39.347.496.5037 Skype: daniele.grosso.genova daniele.grosso@unige.it, daniele.grosso@ge.infn.it daniele.grosso.genova@gmail.com