func (w *World) Update() {
	width := w.width
	height := w.height
	next := make([]bool, width*height)
	for y := 0; y < height; y++ {
		for x := 0; x < width; x++ {
			pop := neighbourCount(w.area, width, height, x, y)
			switch {
			case pop < 2:
				// rule 1. Any live cell with fewer than two live neighbours
				// dies, as if caused by under-population.
				next[y*width+x] = false

			case (pop == 2 || pop == 3) && w.area[y*width+x]:
				// rule 2. Any live cell with two or three live neighbours
				// lives on to the next generation.
				next[y*width+x] = true

			case pop > 3:
				// rule 3. Any live cell with more than three live neighbours
				// dies, as if by over-population.
				next[y*width+x] = false

			case pop == 3:
				// rule 4. Any dead cell with exactly three live neighbours
				// becomes a live cell, as if by reproduction.
				next[y*width+x] = true
			}
		}
	}
	w.area = next
}
func (w *World) Update() {
	width := w.width
	height := w.height
	next := make([]bool, width*height)
	for y := 0; y < height; y++ {
		for x := 0; x < width; x++ {
			pop := neighbourCount(w.area, width, height, x, y)
			switch {
			case pop < 2:
				
				
				next[y*width+x] = false

			case (pop == 2 || pop == 3) && w.area[y*width+x]:
				
				
				next[y*width+x] = true

			case pop > 3:
				
				
				next[y*width+x] = false

			case pop == 3:
				
				
				next[y*width+x] = true
			}
		}
	}
	w.area = next
}
func ( w * World ) Update ( ) { width := w . width height := w . height next := make ( [ ] bool , width * height ) for y := 0 ; y < height ; y ++ { for x := 0 ; x < width ; x ++ { pop := neighbourCount ( w . area , width , height , x , y ) switch { case pop < 2 : // rule 1. Any live cell with fewer than two live neighbours // dies, as if caused by under-population. next [ y * width + x ] = false case ( pop == 2 || pop == 3 ) && w . area [ y * width + x ] : // rule 2. Any live cell with two or three live neighbours // lives on to the next generation. next [ y * width + x ] = true case pop > 3 : // rule 3. Any live cell with more than three live neighbours // dies, as if by over-population. next [ y * width + x ] = false case pop == 3 : // rule 4. Any dead cell with exactly three live neighbours // becomes a live cell, as if by reproduction. next [ y * width + x ] = true } } } w . area = next }
// Update game state by one tick.
Update game state by one tick .