We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
functionbomberMan(n,gridInit){// Grid will have 3 states which are going to get repeated over and over// 1. Grid before explosion ::: gridBeforeExplosion// 2. Grid full of bombs ::: gridFullOfBombs// 3. Grid after explosion ::: gridAfterExplosionletgridBeforeExplosion=[...gridInit];if(n===1)returngridBeforeExplosion;// Nothing happens at second 1constgridFullOfBombs=plantBombs(gridBeforeExplosion);if(n%2===0)returngridFullOfBombs.map(v=>v.join(''));// Every pair second bomberman fills the grid with bombs// from this point onwards every unpair number of seconds we alternate between 2 states// n = 3, 7, 11, 15, 19, 23, ... will always be the same ( (n - 3) % 4 === 0 )// n = 5, 9, 13, 17, 21, 25, ... will always be the same ( (n - 5) % 4 === 0 )letgridAfterExplosion=explosion(gridBeforeExplosion,gridFullOfBombs);if((n-3)%4===0)returngridAfterExplosion;gridBeforeExplosion=[...gridAfterExplosion];gridAfterExplosion=explosion(gridBeforeExplosion,gridFullOfBombs);returngridAfterExplosion;}
The Bomberman Game
You are viewing a single comment's thread. Return to all comments →