Screencast little changes
This commit is contained in:
@@ -16,9 +16,22 @@
|
||||
"## Install requirements"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "0e82420f",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"create a virtual environment in current directory by \n",
|
||||
"\n",
|
||||
"```\n",
|
||||
"python3 -m venv .env # macos\n",
|
||||
"python -m venv .env # linux\n",
|
||||
"```"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": 7,
|
||||
"id": "4a0d404f-b3bf-4984-99ae-e66168289ece",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
@@ -26,25 +39,25 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Requirement already satisfied: prettytable in /Users/safak/Documents/UNI/KI/.env/lib/python3.13/site-packages (3.16.0)\n",
|
||||
"Requirement already satisfied: wcwidth in /Users/safak/Documents/UNI/KI/.env/lib/python3.13/site-packages (from prettytable) (0.2.13)\n",
|
||||
"Requirement already satisfied: prettytable in /home/safak/Dokumente/Uni/KI/.env/lib64/python3.13/site-packages (3.16.0)\n",
|
||||
"Requirement already satisfied: wcwidth in /home/safak/Dokumente/Uni/KI/.env/lib64/python3.13/site-packages (from prettytable) (0.2.13)\n",
|
||||
"Note: you may need to restart the kernel to use updated packages.\n",
|
||||
"Requirement already satisfied: IPython in /Users/safak/Documents/UNI/KI/.env/lib/python3.13/site-packages (9.2.0)\n",
|
||||
"Requirement already satisfied: decorator in /Users/safak/Documents/UNI/KI/.env/lib/python3.13/site-packages (from IPython) (5.2.1)\n",
|
||||
"Requirement already satisfied: ipython-pygments-lexers in /Users/safak/Documents/UNI/KI/.env/lib/python3.13/site-packages (from IPython) (1.1.1)\n",
|
||||
"Requirement already satisfied: jedi>=0.16 in /Users/safak/Documents/UNI/KI/.env/lib/python3.13/site-packages (from IPython) (0.19.2)\n",
|
||||
"Requirement already satisfied: matplotlib-inline in /Users/safak/Documents/UNI/KI/.env/lib/python3.13/site-packages (from IPython) (0.1.7)\n",
|
||||
"Requirement already satisfied: pexpect>4.3 in /Users/safak/Documents/UNI/KI/.env/lib/python3.13/site-packages (from IPython) (4.9.0)\n",
|
||||
"Requirement already satisfied: prompt_toolkit<3.1.0,>=3.0.41 in /Users/safak/Documents/UNI/KI/.env/lib/python3.13/site-packages (from IPython) (3.0.51)\n",
|
||||
"Requirement already satisfied: pygments>=2.4.0 in /Users/safak/Documents/UNI/KI/.env/lib/python3.13/site-packages (from IPython) (2.19.1)\n",
|
||||
"Requirement already satisfied: stack_data in /Users/safak/Documents/UNI/KI/.env/lib/python3.13/site-packages (from IPython) (0.6.3)\n",
|
||||
"Requirement already satisfied: traitlets>=5.13.0 in /Users/safak/Documents/UNI/KI/.env/lib/python3.13/site-packages (from IPython) (5.14.3)\n",
|
||||
"Requirement already satisfied: wcwidth in /Users/safak/Documents/UNI/KI/.env/lib/python3.13/site-packages (from prompt_toolkit<3.1.0,>=3.0.41->IPython) (0.2.13)\n",
|
||||
"Requirement already satisfied: parso<0.9.0,>=0.8.4 in /Users/safak/Documents/UNI/KI/.env/lib/python3.13/site-packages (from jedi>=0.16->IPython) (0.8.4)\n",
|
||||
"Requirement already satisfied: ptyprocess>=0.5 in /Users/safak/Documents/UNI/KI/.env/lib/python3.13/site-packages (from pexpect>4.3->IPython) (0.7.0)\n",
|
||||
"Requirement already satisfied: executing>=1.2.0 in /Users/safak/Documents/UNI/KI/.env/lib/python3.13/site-packages (from stack_data->IPython) (2.2.0)\n",
|
||||
"Requirement already satisfied: asttokens>=2.1.0 in /Users/safak/Documents/UNI/KI/.env/lib/python3.13/site-packages (from stack_data->IPython) (3.0.0)\n",
|
||||
"Requirement already satisfied: pure-eval in /Users/safak/Documents/UNI/KI/.env/lib/python3.13/site-packages (from stack_data->IPython) (0.2.3)\n",
|
||||
"Requirement already satisfied: IPython in /home/safak/Dokumente/Uni/KI/.env/lib64/python3.13/site-packages (9.3.0)\n",
|
||||
"Requirement already satisfied: decorator in /home/safak/Dokumente/Uni/KI/.env/lib64/python3.13/site-packages (from IPython) (5.2.1)\n",
|
||||
"Requirement already satisfied: ipython-pygments-lexers in /home/safak/Dokumente/Uni/KI/.env/lib64/python3.13/site-packages (from IPython) (1.1.1)\n",
|
||||
"Requirement already satisfied: jedi>=0.16 in /home/safak/Dokumente/Uni/KI/.env/lib64/python3.13/site-packages (from IPython) (0.19.2)\n",
|
||||
"Requirement already satisfied: matplotlib-inline in /home/safak/Dokumente/Uni/KI/.env/lib64/python3.13/site-packages (from IPython) (0.1.7)\n",
|
||||
"Requirement already satisfied: pexpect>4.3 in /home/safak/Dokumente/Uni/KI/.env/lib64/python3.13/site-packages (from IPython) (4.9.0)\n",
|
||||
"Requirement already satisfied: prompt_toolkit<3.1.0,>=3.0.41 in /home/safak/Dokumente/Uni/KI/.env/lib64/python3.13/site-packages (from IPython) (3.0.51)\n",
|
||||
"Requirement already satisfied: pygments>=2.4.0 in /home/safak/Dokumente/Uni/KI/.env/lib64/python3.13/site-packages (from IPython) (2.19.1)\n",
|
||||
"Requirement already satisfied: stack_data in /home/safak/Dokumente/Uni/KI/.env/lib64/python3.13/site-packages (from IPython) (0.6.3)\n",
|
||||
"Requirement already satisfied: traitlets>=5.13.0 in /home/safak/Dokumente/Uni/KI/.env/lib64/python3.13/site-packages (from IPython) (5.14.3)\n",
|
||||
"Requirement already satisfied: wcwidth in /home/safak/Dokumente/Uni/KI/.env/lib64/python3.13/site-packages (from prompt_toolkit<3.1.0,>=3.0.41->IPython) (0.2.13)\n",
|
||||
"Requirement already satisfied: parso<0.9.0,>=0.8.4 in /home/safak/Dokumente/Uni/KI/.env/lib64/python3.13/site-packages (from jedi>=0.16->IPython) (0.8.4)\n",
|
||||
"Requirement already satisfied: ptyprocess>=0.5 in /home/safak/Dokumente/Uni/KI/.env/lib64/python3.13/site-packages (from pexpect>4.3->IPython) (0.7.0)\n",
|
||||
"Requirement already satisfied: executing>=1.2.0 in /home/safak/Dokumente/Uni/KI/.env/lib64/python3.13/site-packages (from stack_data->IPython) (2.2.0)\n",
|
||||
"Requirement already satisfied: asttokens>=2.1.0 in /home/safak/Dokumente/Uni/KI/.env/lib64/python3.13/site-packages (from stack_data->IPython) (3.0.0)\n",
|
||||
"Requirement already satisfied: pure-eval in /home/safak/Dokumente/Uni/KI/.env/lib64/python3.13/site-packages (from stack_data->IPython) (0.2.3)\n",
|
||||
"Note: you may need to restart the kernel to use updated packages.\n"
|
||||
]
|
||||
}
|
||||
@@ -64,7 +77,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 8,
|
||||
"id": "feb2b662",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -83,7 +96,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 9,
|
||||
"id": "e6feb484-d124-4d78-96fb-2fc3f9e1f22e",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -102,7 +115,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 10,
|
||||
"id": "ec176f38-2d91-47c3-ba8b-c9cce72f0c64",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -202,7 +215,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 11,
|
||||
"id": "214c239d-c8dc-473d-9bc9-cfcd64f40968",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
@@ -280,7 +293,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 12,
|
||||
"id": "06db06a3-ade5-47b6-8f69-aded023a89f7",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": 12,
|
||||
"id": "55fa613b",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@@ -44,10 +44,7 @@
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Requirement already satisfied: pygame in /home/safak/Dokumente/KI/KI/.env/lib64/python3.13/site-packages (2.6.1)\n",
|
||||
"\n",
|
||||
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m24.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.1.1\u001b[0m\n",
|
||||
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
|
||||
"Requirement already satisfied: pygame in /home/safak/Dokumente/Uni/KI/.env/lib64/python3.13/site-packages (2.6.1)\n",
|
||||
"Note: you may need to restart the kernel to use updated packages.\n"
|
||||
]
|
||||
}
|
||||
@@ -66,7 +63,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 13,
|
||||
"id": "e7034eee",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@@ -74,16 +71,7 @@
|
||||
"start_time": "2025-05-07T21:40:23.718944Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"pygame 2.6.1 (SDL 2.28.4, Python 3.13.0)\n",
|
||||
"Hello from the pygame community. https://www.pygame.org/contribute.html\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pygame\n",
|
||||
"import math"
|
||||
@@ -99,7 +87,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 14,
|
||||
"id": "60b63344",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@@ -119,7 +107,8 @@
|
||||
"\n",
|
||||
"WIDTH = 25\n",
|
||||
"HEIGHT = 25\n",
|
||||
"MARGIN = 3\n"
|
||||
"MARGIN = 3\n",
|
||||
"GRID_SIZE= 20"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -127,12 +116,14 @@
|
||||
"id": "87a05a3b",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Classes "
|
||||
"## Classes \n",
|
||||
"\n",
|
||||
"The Queue Class is the same from Task 1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"execution_count": 15,
|
||||
"id": "84ad596c",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@@ -191,7 +182,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 16,
|
||||
"id": "d3b77c0a",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@@ -229,7 +220,7 @@
|
||||
" color = GREY\n",
|
||||
"\n",
|
||||
" x_calc = (MARGIN + WIDTH) * self.x + MARGIN\n",
|
||||
" y_calc = (MARGIN + HEIGHT) * (grid_size - 1 - self.y) + MARGIN # flipping\n",
|
||||
" y_calc = (MARGIN + HEIGHT) * (GRID_SIZE - 1 - self.y) + MARGIN # flipping\n",
|
||||
"\n",
|
||||
" pygame.draw.rect(\n",
|
||||
" screen,\n",
|
||||
@@ -240,7 +231,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 17,
|
||||
"id": "b3d9f04f",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@@ -332,7 +323,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": 18,
|
||||
"id": "53c20ed6",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@@ -342,14 +333,14 @@
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"grid_size = 20\n",
|
||||
"window_width = grid_size * (WIDTH + MARGIN) + MARGIN\n",
|
||||
"window_height = grid_size * (HEIGHT + MARGIN) + MARGIN\n",
|
||||
"\n",
|
||||
"window_width = GRID_SIZE * (WIDTH + MARGIN) + MARGIN\n",
|
||||
"window_height = GRID_SIZE * (HEIGHT + MARGIN) + MARGIN\n",
|
||||
"size = (window_width, window_height) # made size variable\n",
|
||||
"\n",
|
||||
"start = (0, 0)\n",
|
||||
"target = (19, 19)\n",
|
||||
"grid = Grid(grid_size, grid_size)\n",
|
||||
"grid = Grid(GRID_SIZE, GRID_SIZE)\n",
|
||||
"\n",
|
||||
"# check if start an target are valid\n",
|
||||
"if 0 <= start[0] < grid.cols and 0 <= target[0] < grid.cols and 0 <= start[1] < grid.cols and 0 <= target[\n",
|
||||
@@ -368,7 +359,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": 19,
|
||||
"id": "d01d53b0",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@@ -398,7 +389,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": 20,
|
||||
"id": "d480bcf1",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@@ -426,7 +417,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": 21,
|
||||
"id": "a8c78a46",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@@ -445,7 +436,7 @@
|
||||
" screen.fill(BLACK)\n",
|
||||
" grid.draw(screen)\n",
|
||||
" pygame.display.flip()\n",
|
||||
" clock.tick(30)"
|
||||
" clock.tick(60)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -458,7 +449,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": 22,
|
||||
"id": "4c138642",
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
@@ -499,8 +490,7 @@
|
||||
" update_screen()\n",
|
||||
"\n",
|
||||
" open.clear()\n",
|
||||
" done = True\n",
|
||||
"\n",
|
||||
" # done = True\n",
|
||||
"\n",
|
||||
" closed.push(current_field)\n",
|
||||
" grid.set_visited(current_field.x, current_field.y)\n",
|
||||
@@ -556,7 +546,7 @@
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.13.0"
|
||||
"version": "3.13.3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
|
||||
Reference in New Issue
Block a user