
Convert between RLE, Life 1.06 and Plaintext file formats containing Conway's Game of life patterns. This program may be used as a library or through the command line.
Note: This project was made as part of the Project52 challenge in order to improve my Go skills.
Features
- Convert between any combination of RLE, Life 1.06, and Plaintext file formats.
Installation
If you want to use it as a library:
$ go get github.com/ayoisaiah/life
or if you want to use it via the command line:
$ go get github.com/ayoisaiah/life/cmd/...
The life command should now be available provided the $GOPATH/bin folder is in your path.
You can also download the precompiled binaries for Linux, Windows, and macOS here (only for amd64).
Usage
Library usage
Here's an example that converts one of the RLE patterns hosted here to its Plaintext equivalent.
package main
import (
"fmt"
"log"
"github.com/ayoisaiah/life"
)
func main() {
url := "https://copy.sh/life/examples/123.rle"
p, err := life.PresetFromURL(url, "rle")
if err != nil {
log.Fatal(err)
}
b, err := p.ToPlainText()
if err != nil {
log.Fatal(err)
}
fmt.Println(string(b))
}
# output
!Name: 1-2-3
!A period 3 oscillator that was found in August 1972.
!
..OO......
O..O......
OO.O.OO...
.O.O..O...
.O....O.OO
..OOO.O.OO
.....O....
....O.....
....OO....
Full documentation can be found here.
Command line usage
- Load Plaintext pattern from a file and convert to RLE
$ life --file 101.cells --output rle
#C 101
#C Achim Flammenkamp
#C A period 5 oscillator that was found in August 1994.
#C The name was suggested by Bill Gosper, noting that the phase shown
#C below displays the period in binary.
x = 18, y = 12
4b2o6b2o$3bobo6bobo$3bo10bo$2obo10bob2o$2obobo2b2o2bobob2o$3bobobo2bob
obo$3bobobo2bobobo$2obobo2b2o2bobob2o$2obo10bob2o$3bo10bo$3bobo6bobo$4
b2o6b2o!
- Load RLE pattern from URL and convert to Life 1.06
$ life --url "https://copy.sh/life/examples/gosperglidergun.rle" --input rle --output life106
#Life 1.06
24 0
22 1
24 1
12 2
13 2
20 2
21 2
34 2
35 2
11 3
15 3
20 3
21 3
34 3
35 3
0 4
1 4
10 4
16 4
20 4
21 4
0 5
1 5
10 5
14 5
16 5
17 5
22 5
24 5
10 6
16 6
24 6
11 7
15 7
12 8
13 8
TODO
Credit and sources
Life relies heavily on other open source software listed below:
Contribute
Bug reports, or pull requests are much welcome!
Licence
Created by Ayooluwa Isaiah and released under the terms of the MIT Licence.