Screencast little changes

This commit is contained in:
2025-06-01 21:33:24 +02:00
parent 9acb871d9a
commit a742511152
2 changed files with 63 additions and 60 deletions

View File

@@ -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,