-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
5,048 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "567e2e56-b9fa-49ff-b672-a040cc537818", | ||
"metadata": {}, | ||
"source": [ | ||
"### **Exercise: Game of Life (no xarray, just python practice)**\n", | ||
"\n", | ||
"Implement [Conway's game of life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life) using numpy array to hold data.\n", | ||
"Neighbours are defined as adjacent cells.\n", | ||
"\n", | ||
" - Any LIVING cell with 2 or 3 neighbours survives.\n", | ||
" - Any DEAD cell with 3 neighbours comes alive.\n", | ||
" - Any OTHER LIVING cell dies.\n", | ||
" - All deaths and births occur simultaneously\n", | ||
"\n", | ||
"For plotting: Jupyter is very finicky with \"real-time\" plots and there is a high chance it will refuse to plot everything in one frame even if you try all the stackoverflow solutions, so I propose just using a script to run your program (type \"python FILE_NAME.py\" in console). Try the following code to produce \"animation\" to test that it works:\n", | ||
"\n", | ||
"```\n", | ||
"import numpy as np\n", | ||
"import matplotlib.pyplot as plt\n", | ||
"\n", | ||
"plt.axis([0, 10, 0, 1])\n", | ||
"\n", | ||
"for i in range(10):\n", | ||
" y = np.random.random()\n", | ||
" plt.scatter(i, y)\n", | ||
" plt.pause(0.5)\n", | ||
"plt.show()\n", | ||
"\n", | ||
"```" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "646ae670-4f06-4bef-a161-b2ad0d9a8089", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.8" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.