{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "4fdfd5d1",
   "metadata": {},
   "source": [
    "# 06-15 · Losowy ruch\n",
    "\n",
    "Praktyka do sekcji [„Ruch losowy”"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6006a7bb",
   "metadata": {},
   "source": [
    "## Cel\n",
    "\n",
    "Symuluj losowy spacer (random walk) i zobacz rolę random.seed()."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "044c7983",
   "metadata": {},
   "source": [
    "## Ustawienie (wykonać raz)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "cf4b7dec",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T13:58:23.238955Z",
     "iopub.status.busy": "2026-08-16T13:58:23.238798Z",
     "iopub.status.idle": "2026-08-16T13:58:23.423407Z",
     "shell.execute_reply": "2026-08-16T13:58:23.422891Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Окно Turtle готово.\n"
     ]
    }
   ],
   "source": [
    "import turtle\n",
    "\n",
    "screen = turtle.Screen()\n",
    "artist = turtle.Turtle()\n",
    "artist.pensize(3)\n",
    "artist.pencolor(\"#5B24F9\")\n",
    "print(\"Окно Turtle готово.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3bdcfc88",
   "metadata": {},
   "source": [
    "## Sprawa robocza\n",
    "\n",
    "Random Walk z stałym seed."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "539a2558",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T13:58:23.424440Z",
     "iopub.status.busy": "2026-08-16T13:58:23.424326Z",
     "iopub.status.idle": "2026-08-16T13:58:25.626152Z",
     "shell.execute_reply": "2026-08-16T13:58:25.625756Z"
    }
   },
   "outputs": [],
   "source": [
    "import random\n",
    "\n",
    "artist.reset()\n",
    "random.seed(1)\n",
    "for _ in range(30):\n",
    "    artist.forward(15)\n",
    "    artist.right(random.randint(-60, 60))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8e327828",
   "metadata": {},
   "source": [
    "## Eksperyment 1\n",
    "\n",
    "Uruchom tę samą komórkę od nowa – trajektoria powinna być TAKA sama (ta sama seed)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "cb88e1f5",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T13:58:25.627458Z",
     "iopub.status.busy": "2026-08-16T13:58:25.627339Z",
     "iopub.status.idle": "2026-08-16T13:58:27.839586Z",
     "shell.execute_reply": "2026-08-16T13:58:27.839155Z"
    }
   },
   "outputs": [],
   "source": [
    "artist.reset()\n",
    "random.seed(1)\n",
    "for _ in range(30):\n",
    "    artist.forward(15)\n",
    "    artist.right(random.randint(-60, 60))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b6e2020f",
   "metadata": {},
   "source": [
    "## Podstawowa praktyka zadań ★\n",
    "\n",
    "Uruchom losowy spacer o 50 krokach z random.seed(42)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "6a978ca2",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T13:58:27.840904Z",
     "iopub.status.busy": "2026-08-16T13:58:27.840787Z",
     "iopub.status.idle": "2026-08-16T13:58:31.516883Z",
     "shell.execute_reply": "2026-08-16T13:58:31.516283Z"
    }
   },
   "outputs": [],
   "source": [
    "artist.reset()\n",
    "random.seed(42)\n",
    "for _ in range(50):\n",
    "    artist.forward(15)\n",
    "    artist.right(random.randint(-60, 60))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "58c04b12",
   "metadata": {},
   "source": [
    "## Ukończenie (wykonaj raz, na samym końcu)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "0e11336d",
   "metadata": {
    "execution": {
     "iopub.execute_input": "2026-08-16T13:58:31.517957Z",
     "iopub.status.busy": "2026-08-16T13:58:31.517849Z",
     "iopub.status.idle": "2026-08-16T13:58:31.520780Z",
     "shell.execute_reply": "2026-08-16T13:58:31.520274Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Окно Turtle закрыто.\n"
     ]
    }
   ],
   "source": [
    "screen.bye()\n",
    "print(\"Окно Turtle закрыто.\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Cartesian Python 3.14",
   "language": "python",
   "name": "cartesian-python314"
  },
  "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.14.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
