Tracks
/
MIPS Assembly
MIPS Assembly
/
Exercises
/
Conway's Game of Life
Conway's Game of Life

Conway's Game of Life

Medium

Introduction

Conway's Game of Life is a fascinating cellular automaton created by the British mathematician John Horton Conway in 1970.

The game consists of a two-dimensional grid of cells that can either be "alive" or "dead."

After each generation, the cells interact with their eight neighbors via a set of rules, which define the new generation.

Instructions

After each generation, the cells interact with their eight neighbors, which are cells adjacent horizontally, vertically, or diagonally.

The following rules are applied to each cell:

  • Any live cell with two or three live neighbors lives on.
  • Any dead cell with exactly three live neighbors becomes a live cell.
  • All other cells die or stay dead.

Given a matrix of 1s and 0s (corresponding to live and dead cells), apply the rules to each cell, and return the next generation.

Each row of the grid is represented as a word.

For example,

    0 1 0
    1 0 0
    1 1 0

is represented as

0x2
0x4
0x6

The grid has at most 32 columns.

Registers

Register Usage Type Description
$a0 input integer number of rows
$a1 input integer number of columns
$a2 input address grid for current generation
$a3 input/output address grid for next generation
$t0-9 temporary any used for temporary storage

Source

WikipediaThe link opens in a new window or tab
Edit via GitHub The link opens in a new window or tab
MIPS Assembly Exercism

Ready to start Conway's Game of Life?

Sign up to Exercism to learn and master MIPS Assembly with 61 exercises, and real human mentoring, all for free.