Implementation of Conway's Game of Life in Haskell
This project implements Conway's Game of Life, a cellular automaton devised by the British mathematician John Horton Conway in 1970. The game is a zero-player game, meaning that its evolution is determined by its initial state, requiring no further input. One interacts with the Game of Life by creating an initial configuration and observing how it evolves.
pretty
: Converts a 3D list of characters (representing a grid) into a single string by concatenating lines together with newline characters.glider
: Initial configuration of the glider pattern in Conway's Game of Life.visualisation
: Function to generate a visual representation of the Game of Life grid over multiple generations.evolution
: Function that generates successive generations of the Game of Life based on the rules of the game.main
: The main function that prints the visual representation of the Game of Life for the initial glider pattern.
Make sure you have the Glasgow Haskell Compiler (GHC) installed on your system. You can download it from the Haskell website.
- Open a terminal and navigate to the directory containing the
GameOfLife.hs
file. - Compile the Haskell file using GHC:
ghc GameOfLife.hs -o GameOfLife
- Then run it using:
./GameOfLife.hs
Here is an example output of the Game of Life with the initial glider pattern: