log2life

Feed log lines to sdl2-life as Life 1.05 patterns
git clone https://www.brianlane.com/git/log2life
Log | Files | Refs | README

commit 52d1374d0f6fd17721d4366981b53982d1b06f03
parent 2f7f0433e8bdc311c79cf3070a06d108129d66b2
Author: Brian C. Lane <bcl@brianlane.com>
Date:   Sat, 26 Nov 2022 09:46:19 -0800

Make cmdline args consistent with sdl2-life

Use rows and columns for the world's height and width.

Diffstat:
MREADME.md | 4++--
Mmain.go | 14+++++++-------
2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/README.md b/README.md @@ -9,8 +9,8 @@ x, y coordinate in the Life world. * Download and build [sdl2-life server](https://github.com/bcl/sdl2-life) * Build log2life by running `go build` -* Start the life server with `sdl2-life -rows 255 -columns 255 -server -empty` -* Pass a logfile to the server by running `log2life -width 255 -height 255 /path/to/logfile.log` +* Start the life server with `sdl2-life -rows 250 -columns 250 -server -empty` +* Pass a logfile to the server by running `log2life -rows 250 -columns 250 /path/to/logfile.log` That will use the timestamps in the logfile to replay the requests in realtime. You can control the playback speed by passing '-speed 10' to playback at 10x diff --git a/main.go b/main.go @@ -19,8 +19,8 @@ import ( type cmdlineArgs struct { Logfile string // Logfile to read Speed float64 // Playback speed factor 1.0 == realtime - Width int // Width of Life world in cells - Height int // Height of Life world in cells + Columns int // Columns of Life world in cells + Rows int // Rows of Life world in cells Port int // Port to connect to Host string // Host IP to connect to } @@ -29,8 +29,8 @@ type cmdlineArgs struct { var cfg = cmdlineArgs{ Logfile: "", Speed: 1.0, - Width: 100, - Height: 100, + Columns: 100, + Rows: 100, Port: 3051, Host: "127.0.0.1", } @@ -38,8 +38,8 @@ var cfg = cmdlineArgs{ /* parseArgs handles parsing the cmdline args and setting values in the global cfg struct */ func init() { flag.Float64Var(&cfg.Speed, "speed", cfg.Speed, "Playback speed. 1.0 is realtime") - flag.IntVar(&cfg.Width, "width", cfg.Width, "Width of Life world in cells") - flag.IntVar(&cfg.Height, "height", cfg.Height, "Height of Life world in cells") + flag.IntVar(&cfg.Columns, "columns", cfg.Columns, "Width of Life world in cells") + flag.IntVar(&cfg.Rows, "rows", cfg.Rows, "Height of Life world in cells") flag.IntVar(&cfg.Port, "port", cfg.Port, "Port to listen to") flag.StringVar(&cfg.Host, "host", cfg.Host, "Host IP to bind to") @@ -80,7 +80,7 @@ func main() { lastTime := time.Time{} scanner := bufio.NewScanner(f) for scanner.Scan() { - pattern, timestamp, err := LineToPattern(scanner.Text(), cfg.Width, cfg.Height) + pattern, timestamp, err := LineToPattern(scanner.Text(), cfg.Columns, cfg.Rows) if err != nil { log.Print(err) continue