semvec/pypi-packages huggingface dataset:
life-web-ui 0.1.0.1
Web-based UI for Conway Game of Life
Requires Python: >=3.7

# Web UI for Conway Game of Life

This package is a Web interface for package [conway-life](https://pypi.org/project/conway-life/).

![Web UI Screenshot](https://github.com/kign/life/blob/master/etc/Life_Web_UI.png?raw=true "Web UI Screenshot" )

## Installation

Use PyPi package [life-web-ui](https://pypi.org/project/life-web-ui/)

```bash
python3 -m pip install --upgrade life-web-ui
```

## Usage

Package installs an executable script `life-start` (via common `entry_points` configuration option,
so depending on your local settings it may or may not be in your `$PATH`)

Running this command will start a local server and open it in the default browser. To exit,
press `Ctrl-C` to quit the server and close the browser tab.

```
life-start [-h] [--log {debug,info,warning,error,critical}] [-p PORT]
           [--cell PIXELS] [--space PIXELS] [--padding PIXELS] [-d]

Run Web UI for Game of Life

optional arguments:
  -h, --help            show this help message and exit
  --log {debug,info,warning,error,critical}, --log_level {debug,info,warning,error,critical}
                        Logging level (default = debug)
  -p PORT, --port PORT  Port (default = 13882)
  --cell PIXELS, --size PIXELS
                        Size of cell in pixels (default = 20)
  --space PIXELS        Spacing between cells in pixels
  --padding PIXELS      Canvas padding in pixels
```

## Implementation notes

`life-start` will run a local Flask server. All computations are done in the server
(not in the browser), synchronously on the `Step` command and asynchronously on `Walk` or `Run`.
Asynchronous execution is done with a background Python thread with results polled by the browser.
(`Walk` is different from `Run` in the background thread being suspended between polls).

There is also a short-lived background thread on startup to open Web browser (after a short delay
to make sure server has had time to start). This won't happen if `-d/--dev` option is used (see below).

## Development

For testing purposes, start the server with this command:

```bash
FLASK_ENV=development <VENV_ROOT>/bin/python3 <GIT_ROOT>/py-web/src/life_web_ui/__init__.py -d --log debug
```

Virtual environment installed under `VENV_ROOT` must have all dependencies listed in
[setup.cfg](https://github.com/kign/life/blob/master/py-web/setup.cfg) configuration file for the package (`install_requires`).
conway-life 0.1.4.1
Python interface for game of life
Requires Python: >=3

# Python interface for Game of Life

Python wrapper for C implementation of Conway's Game of Life algorithm.

This only provides low-level utilities. It is intended to be used as a dependency for higher-level
pure Python packages; as of this update, they are:



<table>
  <tr>
    <td><A href="https://pypi.org/project/life-web-ui/">life-web-ui</A></td>
    <td>Web UI for Conway Game of Life</td>
  </tr>
</table>

## Installation

Use PyPi package [conway-life](https://pypi.org/project/conway-life/)

```bash
python3 -m pip install --upgrade conway-life
```

## Design notes

None of the methods allocate any Python objects; output objects must be created by caller.
This both simplifies memory management and makes it possible to avoid unneeded
garbage collection for large objects.

## API

#### run(width, height, n_threads, n_iters, pos_start, pos_end, calllback)

`width`:      Width of the board; *integer*<br>
`height`:     Height of the board; *integer*<br>
`n_threads`:  Number of worker threads (not yet supported); *integer*<br>
`n_iters`:    Number of iterations to run; *integer*<br>
`pos_start`:  Initial position; boolean *list* of size `width` x `height`<br>
`pos_end`:    (Output) Final position; boolean *list* of size `width` x `height`. Must be pre-allocated.<br>
`callback`:   Iteration calllback, or `None` (see below)<br>

return value: number of actually executed iterations
          (never more than `n_iters`, but could be less, see below)<br>

**callback(n_iter, count, bhash, pos_ptr, fin)**

`n_iter`:     current iteration (see below); *integer*<br>
`count`:      count of cells; *integer*<br>
`bhash`:      hash of current position; *integer*<br>
`pos_ptr`:    internal memory pointer to the current position; *integer*.
                Method `read_ptr` can be used to extract the position<br>
`fin`:        1 if this is final iteration, 0 if not<br>

return value: `None` or *integer*; value 1 will trigger iterations to stop immediately.<br>

Notes

  1. `callback` (if defined) is called *before* first iteration, and then
again *after* every iterations, including the last (where fin=1). Therefore,
*normally* callback method is called `1 + n_iters` times.

  1. However this method also detects loops and if your sequence deteriorates
to a loop, it will cut it short; `fin` would still be set to 1 on the last
iteration only regardless. Hash values used in loop detection is passed
to the callback.

#### read_ptr(width, height, pos_ptr, position)

`width`:      Width of the board; *integer*<br>
`height`:     Height of the board; *integer*<br>
`pos_ptr`:    Internal memory pointer returned in a callback (see method `run`); *integer*<br>
`position`:   (Output) Intermediary position; boolean *list* of size `width` x `height`.
                Must be pre-allocated.<br>

return value: 1 on success