> For the complete documentation index, see [llms.txt](https://docs.zama.org/concrete/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zama.org/concrete/2.5/application-tutorials/game_of_life.md).

# Game of Life

In the associated [Python file](https://github.com/zama-ai/concrete/blob/main/frontends/concrete-python/examples/game_of_life/game_of_life.py), you can run the Game of Life, written in Concrete Python.

![Game of Life](https://3729988616-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXuUxUoWPtyPjc9VJ29l4%2Fuploads%2Fgit-blob-6b3f6d420d3f69a8183f5a00f29f212e3bc7a69e%2Fgame-of-life.gif?alt=media)

### Installation

In addition to Concrete, you must install `pygame` in your virtual environment:

* `pip3 install pygame`

Once done, if you go to `frontends/concrete-python/examples/game_of_life`, `python game_of_life.py --help` should give you the manpage:

```
Game of Life in Concrete Python.

options:
  -h, --help            show this help message and exit
  --dimension DIMENSION
                        Dimension of the grid
  --refresh_every REFRESH_EVERY
                        Refresh the grid every X steps
  --method {method_3b,method_4b,method_5b,method_basic}
                        Method for refreshing the grid
  --log2_global_p_error LOG2_GLOBAL_P_ERROR
                        Probability of correctness issue (full circuit)
  --log2_p_error LOG2_P_ERROR
                        Probability of correctness issue (individual TLU)
  --simulate            Simulate instead of running computations in FHE
  --show_mlir           Show the MLIR
  --stop_after_compilation
                        Stop after compilation
  --text_output         Print a text output of the grid
```

### Running

Then, you can play with the different options, and in particular:

* `dimension`, to chose the size of the grid; the larger, the slower
* `method`, to chose which implementation is used for the grid update
* `log2_global_p_error` and `log2_p_error`, to chose the probability of correctness (see the Concrete documentation for more information)
* `simulate`, to do computations only in simulation, i.e., not in FHE

### Typical Executions

In simulation: `python3 game_of_life.py --dimension 100 --refresh_every 50 --simulate`

In FHE: `python3 game_of_life.py --dimension 6 --refresh_every 8 --log2_p_error -40 --method method_4b`

### Technical Explanations

A blog is currently in the process of being written, and a link will be added here when it's available. In the meantime, some explanations are given in the code.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.zama.org/concrete/2.5/application-tutorials/game_of_life.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
