Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save captainabap/f32ac80941354f3aeff4f82ec26fefbc to your computer and use it in GitHub Desktop.
Save captainabap/f32ac80941354f3aeff4f82ec26fefbc to your computer and use it in GitHub Desktop.
create procedure gol( ) as
BEGIN
DECLARE size INT := 10;
DECLARE runde INT := 0;
DECLARE pos_x INT := 0;
DECLARE pos_y INT := 0;
lt_anzahl_nachbarn = select * from matrix;
--100 Runden
while runde <= 5 do
runde = runde + 1;
--Anzeige
select x as "x\y",
sum( case when y = 1 then zelle end ) as "1",
sum( case when y = 2 then zelle end ) as "2",
sum( case when y = 3 then zelle end ) as "3",
sum( case when y = 4 then zelle end ) as "4",
sum( case when y = 5 then zelle end ) as "5",
sum( case when y = 6 then zelle end ) as "6",
sum( case when y = 7 then zelle end ) as "7",
sum( case when y = 8 then zelle end ) as "8",
sum( case when y = 9 then zelle end ) as "9",
sum( case when y = 10 then zelle end ) as "10"
from :lt_anzahl_nachbarn
group by x;
--Aufaddieren
lt_anzahl_nachbarn = select x, y, zelle from :lt_anzahl_nachbarn
union ALL select x+1, y, 1 from :lt_anzahl_nachbarn
union ALL select x-1, y, 1 from :lt_anzahl_nachbarn
union ALL select x, y+1, 1 from :lt_anzahl_nachbarn
union ALL select x, y-1, 1 from :lt_anzahl_nachbarn
union ALL select x+1, y-1, 1 from :lt_anzahl_nachbarn
union ALL select x+1, y+1, 1 from :lt_anzahl_nachbarn
union ALL select x-1, y-1, 1 from :lt_anzahl_nachbarn
union ALL select x+1, y+1, 1 from :lt_anzahl_nachbarn;
lt_anzahl_nachbarn = select x, y, sum( zelle ) as zelle from :lt_anzahl_nachbarn group by x, y;
lt_anzahl_nachbarn = select x,y,10 as zelle from :lt_anzahl_nachbarn where zelle in (3, 12, 13)
and x >= 1
and y <= size;
end while;
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment