https://github.com/splo/gol
Game of Life in Java.
https://github.com/splo/gol
java life
Last synced: 13 days ago
JSON representation
Game of Life in Java.
- Host: GitHub
- URL: https://github.com/splo/gol
- Owner: splo
- Created: 2019-10-11T15:50:12.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-26T14:38:45.000Z (over 6 years ago)
- Last Synced: 2025-02-27T09:59:06.683Z (over 1 year ago)
- Topics: java, life
- Language: Java
- Homepage:
- Size: 79.1 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Game of Life
A simple clone of [Conway's Game of Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life).
## Features
- [x] Customizable grid width and height.
- [x] Customizable grid update frequency and strategy that decides when cells are born and survives.
- [x] Automatically save grid state into a file and reload it at next run.
- [x] Start with a new grid with a random and customizable amound of living cells.
- [x] Run in solo mode or only as a server or client.
- [x] Beautifully display the grid in the console!
## Usage
Once you have a built package, run the command line program `gol`.
If you manually built it, you can find it in `./target/appassembler/bin/gol`.
You can specify the following options:
```
Usage: gol [options]
Options:
-n, --new
Start with a new grid instead of loading the save file
Default: false
-w, --width
Starting grid width
Default: 10
-h, --height
Starting grid height
Default: 10
-a, --alive
Starting grid ratio of alive cells, in %
Default: 15
-f, --frequency
Cell generation update frequency, in Hz
Default: 1.0
-s, --strategy
Strategy for each update, one of
Default: B3S23
-g, --grid-file
Filename of the grid file
Default: grid.gol
--server
Run as a server host
Default: false
--client
Run as a client
Default: false
-p, --port
Port to listen in client or server mode
Default: 9988
--host
Server hostname to connect to
Default: 127.0.0.1
--version
Display version
Default: false
--help
Display help
```
## Development
### Requirements
- Java JDK 13.
### Building
```bash
./mvnw package
```
### Running
```bash
# On Linux/macOS
./target/appassembler/bin/gol
# On Windows
.\target\appassembler\bin\gol.bat
```
To stop the process, hit your Ctrl-C key, or send a SIGINT signal to the process.
### Examples
```bash
# Run with a new grid of size 20x10, with 40% alive cells, updated every 250 ms, with the B12345/S1234,
# saving the grid into the /tmp/grid.gol file, running as a server listening on port 9091:
bin/gol --new --width 20 --alive 40 --frequency 4 --strategy B12345S12345 --grid-file /tmp/grid.gol --port 9091 --server
# Run as a client, connecting to a server at address `127.0.0.1:9091`:
bin/gol --port 9091 --client
```