Skip to content

jiro4989/gameoflife

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gameoflife

gameoflife is Game_of_Life library in pure Nim.

Build Status

1. Development

  • nim >= 1.0.0

2. Install

nimble install gameoflife

3. Usage

3.1. CLI

gameoflife examples/read_file/in/glider.txt

glider.txt is:

00000000000000000000000000000000000000
00000000000000000000000001000000000000
00000000000000000000000101000000000000
00000000000001100000011000000000000110
00000000000010001000011000000000000110
01100000000100000100011000000000000000
01100000000100010110000101000000000000
00000000000100000100000001000000000000
00000000000010001000000000000000000000
00000000000001100000000000000000000000
00000000000000000000000000000000000000
00000000000000000000000000000000000000
00000000000000000000000000000000000000
00000000000000000000000000000000000000
00000000000000000000000000000000000000
00000000000000000000000000000000000000
00000000000000000000000000000000000000
00000000000000000000000000000000000000

3.1.1. Play gameoflife with maze

Generate random data with maze.

Setup:

nimble install -Y maze

And run:

maze -r:1 -w:0 -W:20 -H:20 | gameoflife

Maze

3.2. Library

3.2.1. Blinker example

import gameoflife
from os import sleep

var board: Board = @[
  @[dead, dead, dead, dead, dead],
  @[dead, dead, dead, dead, dead],
  @[dead, live, live, live, dead],
  @[dead, dead, dead, dead, dead],
  @[dead, dead, dead, dead, dead],
]

while true:
  board.nextStep()
  board.print
  echo "-----------------------------------"
  sleep(100)

3.2.2. Glider example

cd examples/read_file
nim c -r main.nim in/glider.txt

Glider animation

5. Web application of Game of Life

I created simple Game of Life on web application.

Javascript library of Game of Life of the application is generated by this module (nimble js).