A simple Game of Life implementation in Java
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.

42 lines
966 B

  1. package edu.stuy.goldfish;
  2. import edu.stuy.goldfish.rules.*;
  3. public class Goldfish {
  4. private Grid _grid;
  5. private Render _render;
  6. public Goldfish () {
  7. int height = 96;
  8. int width = 96;
  9. _render = new Render(width, height);
  10. _grid = new Grid(width, height);
  11. }
  12. public void run () {
  13. //TODO: make it run.
  14. _grid.getPatch(1,0).setState(1);
  15. _grid.getPatch(2,1).setState(1);
  16. _grid.getPatch(2,2).setState(1);
  17. _grid.getPatch(1,2).setState(1);
  18. _grid.getPatch(0,2).setState(1);
  19. System.out.println(_grid);
  20. _grid = LifeWithoutDeath.run(_grid);
  21. System.out.println("------------");
  22. System.out.println(_grid);
  23. _render.setGrid(_grid);
  24. _render.run();
  25. }
  26. public static void main (String[] args) {
  27. Goldfish g = new Goldfish();
  28. while(true) {
  29. g.run();
  30. }
  31. }
  32. }