Skip to content

srozen/raifu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raifu

Conway's Game of Life with GenServers

Description

This Conway's Game of Life implementation through GenServers mainly serves my learing purposes of OTP usage and testing, as well as build process of an Elixir app.

The game of life is composed by a single Board server of dimension x*y that orchestrate x*y Cell. The Cells are dynamically instanciated through a CellSupervisor. The Runner is used to trigger ticks on the Board and display the state of the game to the user.

sequenceDiagram
    participant Runner
    participant Board
    participant CellSupervisor
    participant Cell
    participant OtherCell

    Runner->>Board: start_game
    Board->>CellSupervisor: instantiate cells
    CellSupervisor->>Board: cell_references
    Board->>Runner: :ok
    Runner->>Board: tick
    Board->>Cell: compute_next_state
    Cell->>OtherCell: get_neighborhood_status
    Cell->>Cell: next_state
    Cell->>Board: :ok
    Board->>Cell: update_state
    Cell->>Board: new_state
    Board->>Runner: board_state
    Runner->>Runner: render board
Loading

How to launch it

iex -S mix run --no-halt

# Then in iex, launch the game through the Runner, specifying the dimensions of the board.
Raifu.Runner.start_game(20,20)

The Runner will then display the Game's board and update it upon each tick with the following format :

Conway's Game of Life with GenServers

Releases

No releases published

Packages

No packages published

Languages