noahmpauls/conway-rust

Rust Game of Life

This is a simulator of Conway's Game of Life in Rust, using SDL2 to render the game graphically

. It was built as a Rust learning exercise.

Much of this code is inspired by Ivan Yakushev's rust.game_of_life.

Build/Running

To build from the source:

  1. Clone this repository.
  2. Run cargo build --release. This requires a C compiler to build and link SDL2 libraries; install the recommended C compiler if the build fails.
    • Note: you can also use cargo run, but building in the release configuration is recommended for performance.
  3. Run the conway executable generated in the target/release folder. See below for examples.

Examples

# See all CLI options
.\target\release\conway.exe --help

# Run a random simulation with 450 rows and 600 columns of 2x2 cells.
.\target\release\conway.exe -d 450x600 -c 2

# Run a simulation with the starting pattern in `games/gosper.txt`.
.\target\release\conway.exe -d 100x200 -f games/gosper.txt

Starting and controlling the simulation

The simulation can be initiated using a command line tool with basic options for configuring the intial pattern and how the game is displayed. The simulation can be controlled using keyboard input:

  • The spacebar causes the game to play/pause.
  • The n key single-steps the game when rendering is paused.
  • The up/down arrows increase/decrease the max framerate of the rendering. Depending on the size/complexity of the game being rendered, the actual framerate may fall below this. When the framerate is set to max, the program will attempt to render as fast as it possibly can.
  • The right/left arrows increase/decrease the number of evolutions the game steps through per frame. Setting this to a high value will significantly impact performance.
  • Q or Escape ends the simulation.

Game files

The simulation can be configured to start from a predetermined pattern by passing a path to a pattern file (just a normal text file following a specific syntax). The pattern files can be in one of two formats: chars or coords. Some example files are found in the games directory.

Chars format

The chars format is a visual pattern representation that uses characters to represent dead or alive cells. The first line of the file must be chars:

chars

Then the characters representing dead and live cells are given in curly braces ({<dead><live>}):

{.#}

Finally, the pattern is written by placing dead or live characters in their place visually:

........................#...........
......................#.#...........
............##......##............##
...........#...#....##............##
##........#.....#...##..............
##........#...#.##....#.#...........
..........#.....#.......#...........
...........#...#....................
............##......................

Note that it is not necessary to pad each row with dead cells. The following is equivalent to the above:

........................#
......................#.#
............##......##............##
...........#...#....##............##
##........#.....#...##
##........#...#.##....#.#
..........#.....#.......#
...........#...#
............##

The complete chars pattern file looks like:

chars

{.#}

........................#...........
......................#.#...........
............##......##............##
...........#...#....##............##
##........#.....#...##..............
##........#...#.##....#.#...........
..........#.....#.......#...........
...........#...#....................
............##......................

Coords format

The coords format gives a list of live cells as row,col coordinates. A coords pattern file looks like this:

coords

0,1
1,3
2,0
2,1
2,4
2,5
2,6

Each line has an individual coordinate made of nonnegative integers. The above is equivalent to the following char pattern:

chars

{.#}

.#.....
...#...
##..###

Information - Updated Jul 23, 2022

Stars: 0
Forks: 0
Issues: 0

Command line interface to manage clipboard

you can download a cb-bin (Only x64 is supported)

Command line interface to manage clipboard

Command Line Argument Parser for Rust

It is a simple-to-use, efficient, and full-featured library for parsing command line arguments and subcommands when writing command line, console or terminal applications

Command Line Argument Parser for Rust

Command-line tool for working with LNP/BP technology stack

If the build fails, make sure you are using nightly channel for rust compiler:

Command-line tool for working with LNP/BP technology stack

Command Line Utility for Phylum

The command line interface (CLI) allows users to submit their project package dependencies to Phylum's API for analysis

Command Line Utility for Phylum

Command line json text parsing and processing utility

parsing json compliant with rust and cargo

Command line json text parsing and processing utility

Command line interface for Re:infer

re is the official command line interface for Linux (x86_64-unknown-linux-musl)

Command line interface for Re:infer

Command line interface for TMC, written in Rust

Published Builds will be located to the here

Command line interface for TMC, written in Rust

Command line application for searching in Usage

Command line application for searching in

Command line application for searching in Usage
CLI

171

Command-line tool to mirror installed software on multiple machines

Outputs a human-readable (RON) file to sync between machines:

Command-line tool to mirror installed software on multiple machines

Command-line tool for working with SAS binary — sas7bdat — files

ReadStat library developed by ReadStat repository is included as a readstat-sys crate is created

Command-line tool for working with SAS binary — sas7bdat — files
Facebook Instagram Twitter GitHub Dribbble
Privacy