Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

To draw a grid we need two nested for loops

Game of Life

To draw a grid we need two nested for loops

Game of Life

To draw a grid we need two nested for loops

Game of Life

What are the boundary conditions? We need to know the number of cells along each dimension in the grid.

Game of Life

What are the boundary conditions? We need to know the number of cells along each dimension in the grid.

Game of Life

What are the boundary conditions? We need to know the number of cells along each dimension in the grid.

Game of Life

What are the boundary conditions? We need to know the number of cells along each dimension in the grid.

Game of Life

What are the boundary conditions? We need to know the number of cells along each dimension in the grid.

Game of Life

Let's make the grid 10 cells by 10...

Game of Life

Let's make the grid 10 cells by 10...

Game of Life

Let's make the grid 10 cells by 10...

Game of Life

...and have each cell 10 pixels square.

Game of Life

...and have each cell 10 pixels square.

Game of Life

...and have each cell 10 pixels square.

Game of Life

We know the size of the cells

Game of Life

We know the size of the cells

Game of Life

We know the size of the cells

Game of Life

And the offset is simple to calculate

Game of Life

And the offset is simple to calculate

Game of Life

And the offset is simple to calculate

Game of Life

And the offset is simple to calculate

Game of Life

And the offset is simple to calculate

Game of Life

Now we have a simple grid displayed, but we need to colour in the "live" squares.

Game of Life

Now we have a simple grid displayed, but we need to colour in the "live" squares.

Game of Life

Now we have a simple grid displayed, but we need to colour in the "live" squares.

Game of Life

Now we have a simple grid displayed, but we need to colour in the "live" squares.

Game of Life

Now we have a simple grid displayed, but we need to colour in the "live" squares.

Game of Life

Let's just make cells randomly alive

Game of Life

Let's just make cells randomly alive

Game of Life

Let's just make cells randomly alive

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

And now testing for a live cell involves inspecting the array. We can also make the test a lot more robust.

Game of Life

And now testing for a live cell involves inspecting the array. We can also make the test a lot more robust.

Game of Life

And now testing for a live cell involves inspecting the array. We can also make the test a lot more robust.

Game of Life

And now testing for a live cell involves inspecting the array. We can also make the test a lot more robust.

Game of Life

And now testing for a live cell involves inspecting the array. We can also make the test a lot more robust.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

A simple horizontal translation will mobve the cell from the next grid position to the right into the current position.

Game of Life

A simple horizontal translation will mobve the cell from the next grid position to the right into the current position.

Game of Life

A simple horizontal translation will mobve the cell from the next grid position to the right into the current position.

Game of Life

Oh yes, be careful of the boundary condition! If you have reached the right-hand edge, make the cell blank.

Game of Life

Oh yes, be careful of the boundary condition! If you have reached the right-hand edge, make the cell blank.

Game of Life

Oh yes, be careful of the boundary condition! If you have reached the right-hand edge, make the cell blank.

Game of Life

To trigger the regeneration we must create a button and add it to the applet

Game of Life

To trigger the regeneration we must create a button and add it to the applet

Game of Life

To trigger the regeneration we must create a button and add it to the applet

Game of Life

To trigger the regeneration we must create a button and add it to the applet

Game of Life

To trigger the regeneration we must create a button and add it to the applet

Game of Life

To trigger the regeneration we must create a button and add it to the applet

Game of Life

To trigger the regeneration we must create a button and add it to the applet

Game of Life

Once it has appeared on the applet, it must be told who its EvenListener is...

Game of Life

Once it has appeared on the applet, it must be told who its EvenListener is...

Game of Life

Once it has appeared on the applet, it must be told who its EvenListener is...

Game of Life

...and since it's "the current applet", turn the applet into an event listener by declaring the interface and adding the handler.

Game of Life

...and since it's "the current applet", turn the applet into an event listener by declaring the interface and adding the handler.

Game of Life

...and since it's "the current applet", turn the applet into an event listener by declaring the interface and adding the handler.

Game of Life

...and since it's "the current applet", turn the applet into an event listener by declaring the interface and adding the handler.

Game of Life

...and since it's "the current applet", turn the applet into an event listener by declaring the interface and adding the handler.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

Now that regenerate creates a new board, we must make sure that we save the newly returned board object.

Game of Life

Now that regenerate creates a new board, we must make sure that we save the newly returned board object.

Game of Life

Now that regenerate creates a new board, we must make sure that we save the newly returned board object.

Game of Life

And now let's put in the correct rules for Life. It all depends on the number of neighbours a cell has.

Game of Life

And now let's put in the correct rules for Life. It all depends on the number of neighbours a cell has.

Game of Life

And now let's put in the correct rules for Life. It all depends on the number of neighbours a cell has.

Game of Life

If the cell is alive it needs two or three neighbours to stay alive.

Game of Life

If the cell is alive it needs two or three neighbours to stay alive.

Game of Life

If the cell is alive it needs two or three neighbours to stay alive.

Game of Life

Otherwise, if the cell is dead it needs exactly three neighbours be resurrected.

Game of Life

Otherwise, if the cell is dead it needs exactly three neighbours be resurrected.

Game of Life

Otherwise, if the cell is dead it needs exactly three neighbours be resurrected.

Game of Life

So how to tell how many neighbours you have?

Game of Life

So how to tell how many neighbours you have?

Game of Life

So how to tell how many neighbours you have?

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

We'll have to accumulate an integer value in a result variable and return it

Game of Life

We'll have to accumulate an integer value in a result variable and return it

Game of Life

We'll have to accumulate an integer value in a result variable and return it

Game of Life

We'll have to accumulate an integer value in a result variable and return it

Game of Life

We'll have to accumulate an integer value in a result variable and return it

Game of Life

We'll have to accumulate an integer value in a result variable and return it

Game of Life

We'll have to accumulate an integer value in a result variable and return it

Game of Life

But just make sure you don't add in the current cell because you can't be your own neighbour!

Game of Life

But just make sure you don't add in the current cell because you can't be your own neighbour!

Game of Life

But just make sure you don't add in the current cell because you can't be your own neighbour!

Game of Life

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

Game of Life

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

Game of Life

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

Game of Life

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

Game of Life

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

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

But which cell? The MouseEvent tells us where the mouse was clicked. We can work it out from that.

Game of Life

But which cell? The MouseEvent tells us where the mouse was clicked. We can work it out from that.

Game of Life

But which cell? The MouseEvent tells us where the mouse was clicked. We can work it out from that.

Game of Life

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.

Game of Life

To do this we'll need to have a variable to hold the button...

Game of Life

To do this we'll need to have a variable to hold the button...

Game of Life

To do this we'll need to have a variable to hold the button...

Game of Life

...then create the button...

Game of Life

...then create the button...

Game of Life

...then create the button...

Game of Life

...then add the button to the applet's display...

Game of Life

...then add the button to the applet's display...

Game of Life

...then add the button to the applet's display...

Game of Life

...and finally tell the button what is listening for its events.

Game of Life

...and finally tell the button what is listening for its events.

Game of Life

...and finally tell the button what is listening for its events.

Game of Life

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.

Game of Life

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.

Game of Life

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.

Game of Life

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);
		}
	    }

	}
}