Advertisement
Guest User

Untitled

a guest
Nov 17th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. //P(X=1) = c, P(X=0) = (1-c)
  2. function get01(M, i, j, c){
  3. const a = Math.round(Math.random());
  4. if (a<c){
  5. return 1;
  6. }
  7. else{
  8. return 0;
  9. }
  10. }
  11.  
  12. function get02(M, i, j, c){
  13. const aliveNeighbors = countNeighbors(M, i, j, 'alive');
  14. const deadNeighbors = countNeighbors(M, i, j, 'dead');
  15. return {alive: aliveNeighbors, dead: deadNeighbors};
  16. }
  17.  
  18. function getEntry(param){
  19. if (param == 1){
  20. return get01;
  21. }
  22. if (param == 2){
  23. return get02;
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement