not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
931 B

  1. var initialPattern = function initialPattern() {
  2. return new Array(30).fill(0).map(function () {
  3. return new Array(50).fill(0);
  4. });
  5. };
  6. var generateRandomBoardState = function generateRandomBoardState() {
  7. return new Array(30).fill(0).map(function () {
  8. var row = new Array(50).fill(0);
  9. return row.map(function () {
  10. return Math.floor(Math.random() * 2);
  11. });
  12. });
  13. };
  14. var glider = function glider() {
  15. var pattern = initialPattern();
  16. pattern[5][7] = 1;
  17. pattern[6][5] = 1;
  18. pattern[6][6] = 1;
  19. pattern[7][6] = 1;
  20. pattern[7][7] = 1;
  21. return pattern;
  22. };
  23. var no = function no() {
  24. var pattern = initialPattern();
  25. for (var j = 0; j < 30; j++) {
  26. if (!((j + 1) % 4 === 0)) {
  27. for (var i = 2; i < 50; i += 4) {
  28. pattern[j][i] = 1;
  29. }
  30. }
  31. }
  32. return pattern;
  33. };
  34. var patterns = [generateRandomBoardState, glider, no, initialPattern];
  35. define(function () {
  36. return patterns;
  37. });