To play the Game of Life, you need to be able to draw a grid of changing cells. So let's adapt the first applet that we encountered.
To play the Game of Life, you need to be able to draw a grid of changing cells. So let's adapt the first applet that we encountered.
To play the Game of Life, you need to be able to draw a grid of changing cells. So let's adapt the first applet that we encountered.
To draw a grid we need two nested for loops
To draw a grid we need two nested for loops
To draw a grid we need two nested for loops
What are the boundary conditions? We need to know the number of cells along each dimension in the grid.
What are the boundary conditions? We need to know the number of cells along each dimension in the grid.
What are the boundary conditions? We need to know the number of cells along each dimension in the grid.
What are the boundary conditions? We need to know the number of cells along each dimension in the grid.
What are the boundary conditions? We need to know the number of cells along each dimension in the grid.
Let's make the grid 10 cells by 10...
Let's make the grid 10 cells by 10...
Let's make the grid 10 cells by 10...
...and have each cell 10 pixels square.
...and have each cell 10 pixels square.
...and have each cell 10 pixels square.
We know the size of the cells
We know the size of the cells
We know the size of the cells
And the offset is simple to calculate
And the offset is simple to calculate
And the offset is simple to calculate
And the offset is simple to calculate
And the offset is simple to calculate
Now we have a simple grid displayed, but we need to colour in the "live" squares.
Now we have a simple grid displayed, but we need to colour in the "live" squares.
Now we have a simple grid displayed, but we need to colour in the "live" squares.
Now we have a simple grid displayed, but we need to colour in the "live" squares.
Now we have a simple grid displayed, but we need to colour in the "live" squares.
Let's just make cells randomly alive
Let's just make cells randomly alive
Let's just make cells randomly alive
To play life, we have to model the "board" or grid of cells. This gives us some sytate: currently the applet produces a new pattern each time a redraw occurs. We need to model whether each cell is either alive or not, so we can use an array of arrays of boolean values. This array can be initialized in the applet's init method, using a familiar nested for-loop.
To play life, we have to model the "board" or grid of cells. This gives us some sytate: currently the applet produces a new pattern each time a redraw occurs. We need to model whether each cell is either alive or not, so we can use an array of arrays of boolean values. This array can be initialized in the applet's init method, using a familiar nested for-loop.
To play life, we have to model the "board" or grid of cells. This gives us some sytate: currently the applet produces a new pattern each time a redraw occurs. We need to model whether each cell is either alive or not, so we can use an array of arrays of boolean values. This array can be initialized in the applet's init method, using a familiar nested for-loop.
To play life, we have to model the "board" or grid of cells. This gives us some sytate: currently the applet produces a new pattern each time a redraw occurs. We need to model whether each cell is either alive or not, so we can use an array of arrays of boolean values. This array can be initialized in the applet's init method, using a familiar nested for-loop.
To play life, we have to model the "board" or grid of cells. This gives us some sytate: currently the applet produces a new pattern each time a redraw occurs. We need to model whether each cell is either alive or not, so we can use an array of arrays of boolean values. This array can be initialized in the applet's init method, using a familiar nested for-loop.
And now testing for a live cell involves inspecting the array. We can also make the test a lot more robust.
And now testing for a live cell involves inspecting the array. We can also make the test a lot more robust.
And now testing for a live cell involves inspecting the array. We can also make the test a lot more robust.
And now testing for a live cell involves inspecting the array. We can also make the test a lot more robust.
And now testing for a live cell involves inspecting the array. We can also make the test a lot more robust.
Now we can worry about makeing the changes for a new generation. For this we will need to have a method that encodes the "regeneration algorithm" and a button that triggers the regeneration. Let's choose a simple algorithm at first: a horizontal translation. Whatever it is it will use a nested for-loop.
Now we can worry about makeing the changes for a new generation. For this we will need to have a method that encodes the "regeneration algorithm" and a button that triggers the regeneration. Let's choose a simple algorithm at first: a horizontal translation. Whatever it is it will use a nested for-loop.
Now we can worry about makeing the changes for a new generation. For this we will need to have a method that encodes the "regeneration algorithm" and a button that triggers the regeneration. Let's choose a simple algorithm at first: a horizontal translation. Whatever it is it will use a nested for-loop.
A simple horizontal translation will mobve the cell from the next grid position to the right into the current position.
A simple horizontal translation will mobve the cell from the next grid position to the right into the current position.
A simple horizontal translation will mobve the cell from the next grid position to the right into the current position.
Oh yes, be careful of the boundary condition! If you have reached the right-hand edge, make the cell blank.
Oh yes, be careful of the boundary condition! If you have reached the right-hand edge, make the cell blank.
Oh yes, be careful of the boundary condition! If you have reached the right-hand edge, make the cell blank.
To trigger the regeneration we must create a button and add it to the applet
To trigger the regeneration we must create a button and add it to the applet
To trigger the regeneration we must create a button and add it to the applet
To trigger the regeneration we must create a button and add it to the applet
To trigger the regeneration we must create a button and add it to the applet
To trigger the regeneration we must create a button and add it to the applet
To trigger the regeneration we must create a button and add it to the applet
Once it has appeared on the applet, it must be told who its EvenListener is...
Once it has appeared on the applet, it must be told who its EvenListener is...
Once it has appeared on the applet, it must be told who its EvenListener is...
...and since it's "the current applet", turn the applet into an event listener by declaring the interface and adding the handler.
...and since it's "the current applet", turn the applet into an event listener by declaring the interface and adding the handler.
...and since it's "the current applet", turn the applet into an event listener by declaring the interface and adding the handler.
...and since it's "the current applet", turn the applet into an event listener by declaring the interface and adding the handler.
...and since it's "the current applet", turn the applet into an event listener by declaring the interface and adding the handler.
This applet is successfully playing a game, but it's not the Game of Life. It's just the Game of Sliding. The Rules of Life are more complicated, and they change parts of the board before they can be regenerated. Consequently, we need two boards: a current board (which represents the current state of play) and a new board (which represents how the board will turn out after the regeneration. So let's make the regenerate method return a new board each time.
This applet is successfully playing a game, but it's not the Game of Life. It's just the Game of Sliding. The Rules of Life are more complicated, and they change parts of the board before they can be regenerated. Consequently, we need two boards: a current board (which represents the current state of play) and a new board (which represents how the board will turn out after the regeneration. So let's make the regenerate method return a new board each time.
This applet is successfully playing a game, but it's not the Game of Life. It's just the Game of Sliding. The Rules of Life are more complicated, and they change parts of the board before they can be regenerated. Consequently, we need two boards: a current board (which represents the current state of play) and a new board (which represents how the board will turn out after the regeneration. So let's make the regenerate method return a new board each time.
This applet is successfully playing a game, but it's not the Game of Life. It's just the Game of Sliding. The Rules of Life are more complicated, and they change parts of the board before they can be regenerated. Consequently, we need two boards: a current board (which represents the current state of play) and a new board (which represents how the board will turn out after the regeneration. So let's make the regenerate method return a new board each time.
This applet is successfully playing a game, but it's not the Game of Life. It's just the Game of Sliding. The Rules of Life are more complicated, and they change parts of the board before they can be regenerated. Consequently, we need two boards: a current board (which represents the current state of play) and a new board (which represents how the board will turn out after the regeneration. So let's make the regenerate method return a new board each time.
This applet is successfully playing a game, but it's not the Game of Life. It's just the Game of Sliding. The Rules of Life are more complicated, and they change parts of the board before they can be regenerated. Consequently, we need two boards: a current board (which represents the current state of play) and a new board (which represents how the board will turn out after the regeneration. So let's make the regenerate method return a new board each time.
This applet is successfully playing a game, but it's not the Game of Life. It's just the Game of Sliding. The Rules of Life are more complicated, and they change parts of the board before they can be regenerated. Consequently, we need two boards: a current board (which represents the current state of play) and a new board (which represents how the board will turn out after the regeneration. So let's make the regenerate method return a new board each time.
This applet is successfully playing a game, but it's not the Game of Life. It's just the Game of Sliding. The Rules of Life are more complicated, and they change parts of the board before they can be regenerated. Consequently, we need two boards: a current board (which represents the current state of play) and a new board (which represents how the board will turn out after the regeneration. So let's make the regenerate method return a new board each time.
This applet is successfully playing a game, but it's not the Game of Life. It's just the Game of Sliding. The Rules of Life are more complicated, and they change parts of the board before they can be regenerated. Consequently, we need two boards: a current board (which represents the current state of play) and a new board (which represents how the board will turn out after the regeneration. So let's make the regenerate method return a new board each time.
This applet is successfully playing a game, but it's not the Game of Life. It's just the Game of Sliding. The Rules of Life are more complicated, and they change parts of the board before they can be regenerated. Consequently, we need two boards: a current board (which represents the current state of play) and a new board (which represents how the board will turn out after the regeneration. So let's make the regenerate method return a new board each time.
This applet is successfully playing a game, but it's not the Game of Life. It's just the Game of Sliding. The Rules of Life are more complicated, and they change parts of the board before they can be regenerated. Consequently, we need two boards: a current board (which represents the current state of play) and a new board (which represents how the board will turn out after the regeneration. So let's make the regenerate method return a new board each time.
Now that regenerate creates a new board, we must make sure that we save the newly returned board object.
Now that regenerate creates a new board, we must make sure that we save the newly returned board object.
Now that regenerate creates a new board, we must make sure that we save the newly returned board object.
And now let's put in the correct rules for Life. It all depends on the number of neighbours a cell has.
And now let's put in the correct rules for Life. It all depends on the number of neighbours a cell has.
And now let's put in the correct rules for Life. It all depends on the number of neighbours a cell has.
If the cell is alive it needs two or three neighbours to stay alive.
If the cell is alive it needs two or three neighbours to stay alive.
If the cell is alive it needs two or three neighbours to stay alive.
Otherwise, if the cell is dead it needs exactly three neighbours be resurrected.
Otherwise, if the cell is dead it needs exactly three neighbours be resurrected.
Otherwise, if the cell is dead it needs exactly three neighbours be resurrected.
So how to tell how many neighbours you have?
So how to tell how many neighbours you have?
So how to tell how many neighbours you have?
Just look in the previous, current and next columns of the previous, current and next rows and add up all the live squares. That's just a microcosm of the nested for loops that we've seen before.
Just look in the previous, current and next columns of the previous, current and next rows and add up all the live squares. That's just a microcosm of the nested for loops that we've seen before.
Just look in the previous, current and next columns of the previous, current and next rows and add up all the live squares. That's just a microcosm of the nested for loops that we've seen before.
We'll have to accumulate an integer value in a result variable and return it
We'll have to accumulate an integer value in a result variable and return it
We'll have to accumulate an integer value in a result variable and return it
We'll have to accumulate an integer value in a result variable and return it
We'll have to accumulate an integer value in a result variable and return it
We'll have to accumulate an integer value in a result variable and return it
We'll have to accumulate an integer value in a result variable and return it
But just make sure you don't add in the current cell because you can't be your own neighbour!
But just make sure you don't add in the current cell because you can't be your own neighbour!
But just make sure you don't add in the current cell because you can't be your own neighbour!
This is great, but it's a bit frustrating because you have to rely on a good randow pattern. It would be much better to be able to tweak the pattern. We'll do that by clicking on a cell to toggle its aliveness. To do that we need to make the applet receptive to mouse clicks, which we can do by turning it into a mouse listener
This is great, but it's a bit frustrating because you have to rely on a good randow pattern. It would be much better to be able to tweak the pattern. We'll do that by clicking on a cell to toggle its aliveness. To do that we need to make the applet receptive to mouse clicks, which we can do by turning it into a mouse listener
This is great, but it's a bit frustrating because you have to rely on a good randow pattern. It would be much better to be able to tweak the pattern. We'll do that by clicking on a cell to toggle its aliveness. To do that we need to make the applet receptive to mouse clicks, which we can do by turning it into a mouse listener
This is great, but it's a bit frustrating because you have to rely on a good randow pattern. It would be much better to be able to tweak the pattern. We'll do that by clicking on a cell to toggle its aliveness. To do that we need to make the applet receptive to mouse clicks, which we can do by turning it into a mouse listener
This is great, but it's a bit frustrating because you have to rely on a good randow pattern. It would be much better to be able to tweak the pattern. We'll do that by clicking on a cell to toggle its aliveness. To do that we need to make the applet receptive to mouse clicks, which we can do by turning it into a mouse listener
Now a mouse listener must have the appropriate methods to handle mouse events. We want to handle ONE of them (what happens when the mouse is clicked) but Java insists that we put in definitions for all of them.
Now a mouse listener must have the appropriate methods to handle mouse events. We want to handle ONE of them (what happens when the mouse is clicked) but Java insists that we put in definitions for all of them.
Now a mouse listener must have the appropriate methods to handle mouse events. We want to handle ONE of them (what happens when the mouse is clicked) but Java insists that we put in definitions for all of them.
Now a mouse listener must have the appropriate methods to handle mouse events. We want to handle ONE of them (what happens when the mouse is clicked) but Java insists that we put in definitions for all of them.
Now a mouse listener must have the appropriate methods to handle mouse events. We want to handle ONE of them (what happens when the mouse is clicked) but Java insists that we put in definitions for all of them.
Now a mouse listener must have the appropriate methods to handle mouse events. We want to handle ONE of them (what happens when the mouse is clicked) but Java insists that we put in definitions for all of them.
Now a mouse listener must have the appropriate methods to handle mouse events. We want to handle ONE of them (what happens when the mouse is clicked) but Java insists that we put in definitions for all of them.
Now a mouse listener must have the appropriate methods to handle mouse events. We want to handle ONE of them (what happens when the mouse is clicked) but Java insists that we put in definitions for all of them.
Now a mouse listener must have the appropriate methods to handle mouse events. We want to handle ONE of them (what happens when the mouse is clicked) but Java insists that we put in definitions for all of them.
Now a mouse listener must have the appropriate methods to handle mouse events. We want to handle ONE of them (what happens when the mouse is clicked) but Java insists that we put in definitions for all of them.
Now a mouse listener must have the appropriate methods to handle mouse events. We want to handle ONE of them (what happens when the mouse is clicked) but Java insists that we put in definitions for all of them.
So now that we are (technically) handling the mouse events lets actually do something usefull when the mouse is clicked. We want to toggle the state of one of the cells and then redraw the board.
So now that we are (technically) handling the mouse events lets actually do something usefull when the mouse is clicked. We want to toggle the state of one of the cells and then redraw the board.
So now that we are (technically) handling the mouse events lets actually do something usefull when the mouse is clicked. We want to toggle the state of one of the cells and then redraw the board.
But which cell? The MouseEvent tells us where the mouse was clicked. We can work it out from that.
But which cell? The MouseEvent tells us where the mouse was clicked. We can work it out from that.
But which cell? The MouseEvent tells us where the mouse was clicked. We can work it out from that.
Now the only thing that is irritating is the fact that we can't 'start from scratch', but we have to click all the cells off manually. Let's put in a 'Clear' button.
To do this we'll need to have a variable to hold the button...
To do this we'll need to have a variable to hold the button...
To do this we'll need to have a variable to hold the button...
...then create the button...
...then create the button...
...then create the button...
...then add the button to the applet's display...
...then add the button to the applet's display...
...then add the button to the applet's display...
...and finally tell the button what is listening for its events.
...and finally tell the button what is listening for its events.
...and finally tell the button what is listening for its events.
The button is in place, it just doesn't do the right thing. We'll have to handle the event by distinguishing between which of the buttons was pressed.
The button is in place, it just doesn't do the right thing. We'll have to handle the event by distinguishing between which of the buttons was pressed.
The button is in place, it just doesn't do the right thing. We'll have to handle the event by distinguishing between which of the buttons was pressed.
That's it.
import java.awt.Graphics;
import java.applet.Applet;
public class HelloWorld extends Applet {
public void paint(Graphics g){
g.drawString("Hello World", 100, 100);
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class HelloWorld extends Applet {
public void paint(Graphics g){
g.drawString("Hello World", 100, 100);
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
public void paint(Graphics g){
g.drawString("Hello World", 100, 100);
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
public void paint(Graphics g){
g.drawString("Hello World", 100, 100);
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
public void paint(Graphics g){
g.drawString("Hello World", 100, 100);
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
public void paint(Graphics g){
int c, d;
for(c=0; c<??; c++){
for(d=0; d< ??; d++){
g.drawRect(?,?,?,?);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
public void paint(Graphics g){
int c, d;
for(c=0; c<??; c++){
for(d=0; d< ??; d++){
g.drawRect(?,?,?,?);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
public void paint(Graphics g){
int c, d;
for(c=0; c<??; c++){
for(d=0; d< ??; d++){
g.drawRect(?,?,?,?);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d< ??; d++){
g.drawRect(?,?,?,?);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d< ??; d++){
g.drawRect(?,?,?,?);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
g.drawRect(?,?,?,?);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
g.drawRect(?,?,?,?);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
*public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
g.drawRect(?,?,?,?);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10;
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
g.drawRect(?,?,?,?);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10;
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
g.drawRect(?,?,?,?);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10;
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
g.drawRect(?,?,?,?);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
g.drawRect(?,?,?,?);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
g.drawRect(?,?,?,?);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
g.drawRect(?,?,?,?);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
g.drawRect(?,?,cellsize,cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
g.drawRect(?,?,cellsize,cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
g.drawRect(?,?,cellsize,cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
g.drawRect(c*cellsize,?,cellsize,cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
g.drawRect(c*cellsize,?,cellsize,cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
g.drawRect(c*cellsize,d*cellsize,cellsize,cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
g.drawRect(c*cellsize,d*cellsize,cellsize,cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
g.drawRect(c*cellsize,d*cellsize,cellsize,cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
*public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean liveCell(int c, int d){
??
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean liveCell(int c, int d){
??
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean liveCell(int c, int d){
??
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean liveCell(int c, int d){
return Math.random()<0.1;
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean liveCell(int c, int d){
return Math.random()<0.1;
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
*boolean liveCell(int c, int d){
return Math.random()<0.1;
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
return Math.random()<0.1;
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
return Math.random()<0.1;
}
*public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
return Math.random()<0.1;
}
public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
return Math.random()<0.1;
}
public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
return Math.random()<0.1;
}
public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
return theboard[c][d];
}
public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
*return theboard[c][d];
}
public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
*public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=??;
}
}
}
public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=??;
}
}
}
public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=??;
}
}
}
public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=board[c+1][d];
}
}
}
public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=board[c+1][d];
}
}
}
public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
*board[c][d]=board[c+1][d];
}
}
}
public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.Graphics;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
*public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
public void init(){
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
public void init(){
*theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
public void init(){
generateButton=new Button("Generate");
add(generateButton);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
public void init(){
generateButton=new Button("Generate");
add(generateButton);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
public void init(){
generateButton=new Button("Generate");
add(generateButton);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
*public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
void regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
*int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)board[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)newboard[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)newboard[c][d]=false;
else board[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)newboard[c][d]=false;
else newboard[c][d]=board[c+1][d];
}
}
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)newboard[c][d]=false;
else newboard[c][d]=board[c+1][d];
}
}
* }
private Button generateButton;
public void actionPerformed(ActionEvent event){
regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)newboard[c][d]=false;
else newboard[c][d]=board[c+1][d];
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)newboard[c][d]=false;
else newboard[c][d]=board[c+1][d];
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)newboard[c][d]=false;
else newboard[c][d]=board[c+1][d];
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
*regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)newboard[c][d]=false;
else newboard[c][d]=board[c+1][d];
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)newboard[c][d]=false;
else newboard[c][d]=board[c+1][d];
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(c==ncells-1)newboard[c][d]=false;
else newboard[c][d]=board[c+1][d];
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
*boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
??
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
??
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
??
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(liveCell(c+x,d+y))??;
}
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(liveCell(c+x,d+y))??;
}
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
*int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(liveCell(c+x,d+y))??;
}
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(liveCell(c+x,d+y))??;
}
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(liveCell(c+x,d+y))??;
}
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(liveCell(c+x,d+y))result++;
}
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(liveCell(c+x,d+y))result++;
}
*}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
*if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
*theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
*public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
*public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
*public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
*public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
*public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
*}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
*theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
int cellx=event.getX()/cellsize;
int celly=event.getY()/cellsize;
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
int cellx=event.getX()/cellsize;
int celly=event.getY()/cellsize;
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
int cellx=event.getX()/cellsize;
int celly=event.getY()/cellsize;
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
int cellx=event.getX()/cellsize;
int celly=event.getY()/cellsize;
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton, clearButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
int cellx=event.getX()/cellsize;
int celly=event.getY()/cellsize;
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton, clearButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
int cellx=event.getX()/cellsize;
int celly=event.getY()/cellsize;
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton, clearButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
int cellx=event.getX()/cellsize;
int celly=event.getY()/cellsize;
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
*this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton, clearButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
int cellx=event.getX()/cellsize;
int celly=event.getY()/cellsize;
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
clearButton=new Button("Clear");
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton, clearButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
int cellx=event.getX()/cellsize;
int celly=event.getY()/cellsize;
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
clearButton=new Button("Clear");
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton, clearButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
int cellx=event.getX()/cellsize;
int celly=event.getY()/cellsize;
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
clearButton=new Button("Clear");
*this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton, clearButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
int cellx=event.getX()/cellsize;
int celly=event.getY()/cellsize;
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
clearButton=new Button("Clear");
add(clearButton);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton, clearButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
int cellx=event.getX()/cellsize;
int celly=event.getY()/cellsize;
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
clearButton=new Button("Clear");
add(clearButton);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton, clearButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
int cellx=event.getX()/cellsize;
int celly=event.getY()/cellsize;
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
clearButton=new Button("Clear");
add(clearButton);
*this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton, clearButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
int cellx=event.getX()/cellsize;
int celly=event.getY()/cellsize;
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
clearButton=new Button("Clear");
add(clearButton);
clearButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton, clearButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
int cellx=event.getX()/cellsize;
int celly=event.getY()/cellsize;
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
clearButton=new Button("Clear");
add(clearButton);
clearButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton, clearButton;
public void actionPerformed(ActionEvent event){
theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
int cellx=event.getX()/cellsize;
int celly=event.getY()/cellsize;
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
clearButton=new Button("Clear");
add(clearButton);
clearButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton, clearButton;
public void actionPerformed(ActionEvent event){
if(event.getSource()==clearButton)theboard=new boolean[ncells][ncells];
else theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
int cellx=event.getX()/cellsize;
int celly=event.getY()/cellsize;
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
clearButton=new Button("Clear");
add(clearButton);
clearButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}
import java.awt.*;
import java.applet.Applet;
public class Life extends Applet implements ActionListener, MouseListener {
final int ncells=10, cellsize=10;
boolean[][] theboard;
boolean liveCell(int c, int d){
if(c<0 || d<0 || c>=ncells || d>=ncells)return false;
return theboard[c][d];
}
int neighboursOf(int c, int d){
int result=0;
int x, y;
for(x=-1; x<=1; x++)
for(y=-1; y<=1; y++){
if(x==0 && y==0)continue;
if(liveCell(c+x,d+y))result++;
}
return result;
}
boolean[][] regenerate(boolean[][] board){
boolean[][] newboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
int n=neighboursOf(c,d);
if(liveCell(c,d)) newboard[c][d] = n==2||n==3;
else newboard[c][d]=n==3;
}
}
return newboard;
}
private Button generateButton, clearButton;
public void actionPerformed(ActionEvent event){
if(event.getSource()==clearButton)theboard=new boolean[ncells][ncells];
else theboard=regenerate(theboard);
repaint();
}
public void mouseEntered(MouseEvent event){
}
public void mouseExited(MouseEvent event){
}
public void mousePressed(MouseEvent event){
}
public void mouseReleased(MouseEvent event){
}
public void mouseClicked(MouseEvent event){
int cellx=event.getX()/cellsize;
int celly=event.getY()/cellsize;
theboard[cellx][celly]=!theboard[cellx][celly];
repaint();
}
public void init(){
generateButton=new Button("Generate");
add(generateButton);
generateButton.addActionListener(this);
clearButton=new Button("Clear");
add(clearButton);
clearButton.addActionListener(this);
this.addMouseListener(this);
theboard=new boolean[ncells][ncells];
int c,d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
board[c][d]=Math.random()<0.1;
}
}
}
public void paint(Graphics g){
int c, d;
for(c=0; c<ncells; c++){
for(d=0; d<ncells; d++){
if(liveCell(c,d))g.fillRect(c*cellsize,d*cellsize,cellsize, cellsize);
else g.drawRect(c*cellsize,d*cellsize,cellsize, cellsize);
}
}
}
}