Explorar el Código

Better setup() for Conway4; fix funky markdown in readme; safety.

master
Ben Kurtovic hace 11 años
padre
commit
2f8ea8dfba
Se han modificado 3 ficheros con 9 adiciones y 9 borrados
  1. +1
    -1
      README.md
  2. +2
    -0
      src/edu/stuy/goldfish/Goldfish.java
  3. +6
    -8
      src/edu/stuy/goldfish/rules/Conway4.java

+ 1
- 1
README.md Ver fichero

@@ -1,7 +1,7 @@
goldfish
========

**goldfish** (*GoLdfish*) is a simple Game of Life implementation in Java.
**goldfish** (GoLdfish) is a simple Game of Life implementation in Java.

Setup
-----


+ 2
- 0
src/edu/stuy/goldfish/Goldfish.java Ver fichero

@@ -20,7 +20,9 @@ public class Goldfish {
setup(_render.rule);
while (true) {
if (_render.reset) {
_render.acquireLock(0);
setup(_render.rule);
_render.releaseLock(0);
_render.reset = false;
}
if (!_render.paused) {


+ 6
- 8
src/edu/stuy/goldfish/rules/Conway4.java Ver fichero

@@ -1,5 +1,7 @@
package edu.stuy.goldfish.rules;

import java.util.Random;

import edu.stuy.goldfish.Grid;
import edu.stuy.goldfish.Patch;

@@ -27,14 +29,10 @@ public class Conway4 extends RuleSet {
}

public static void setup(Grid g) {
int[][] pattern = {
{1,1,1,1,0,1},
{1,0,1,1,1,1}
};
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 2; j++) {
g.getPatch(i + ((g.getWidth() - 6) / 2),
j + ((g.getHeight() - 2) / 2)).setState(pattern[j][i]);
Random random = new Random();
for (int i = 0; i < g.getWidth(); i++) {
for (int j = 0; j < g.getHeight(); j++) {
g.getPatch(i, j).setState(random.nextInt(2));
}
}
}


Cargando…
Cancelar
Guardar