Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function checkCell($cells, $x, $y, $sizeX, $sizeY){
- $counter = 0;
- $cellState = $cells[$x][$y];
- for($ycell = $y-1; $ycell < $y+1; $ycell++){
- if($ycell >= 0 && $ycell < $sizeY){
- for($xcell = $x-1; $xcell < $x+1; $xcell++){
- if($xcell >= 0 && $xcell < $sizeX){
- // SI CELLULE VIVANTE ET DIFFERENTE DE CELLULE CENTRALE
- if($cells[$xcell][$ycell] == 'o'){
- $counter++;
- }
- }
- }
- }
- }
- if($cellState == 'o') {
- if($counter > 3 || $counter < 2)
- $cellState = ' ';
- }
- if($counter == 3){
- $cellState = 'o';
- console_log("Generate");
- }
- return $cellState;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement