59 lines
1.5 KiB
Plaintext
59 lines
1.5 KiB
Plaintext
|
|
{
|
||
|
|
"cells": [
|
||
|
|
{
|
||
|
|
"cell_type": "code",
|
||
|
|
"execution_count": null,
|
||
|
|
"id": "3a6bb811-80ad-4ef5-95b6-0b7cffc6545e",
|
||
|
|
"metadata": {},
|
||
|
|
"outputs": [],
|
||
|
|
"source": [
|
||
|
|
"from dataclasses import dataclass\n",
|
||
|
|
"from typing import Optional\n",
|
||
|
|
"\n",
|
||
|
|
"@dataclass\n",
|
||
|
|
"class Cell:\n",
|
||
|
|
" \"\"\"Клетка лабиринта.\"\"\"\n",
|
||
|
|
" x: int\n",
|
||
|
|
" y: int\n",
|
||
|
|
" is_wall: bool = False\n",
|
||
|
|
" is_start: bool = False\n",
|
||
|
|
" is_exit: bool = False\n",
|
||
|
|
" weight: int = 1 # Для взвешенных лабиринтов (доп. задание)\n",
|
||
|
|
" \n",
|
||
|
|
" def is_passable(self) -> bool:\n",
|
||
|
|
" \"\"\"Проходима ли клетка.\"\"\"\n",
|
||
|
|
" return not self.is_wall\n",
|
||
|
|
" \n",
|
||
|
|
" def __hash__(self) -> int:\n",
|
||
|
|
" return hash((self.x, self.y))\n",
|
||
|
|
" \n",
|
||
|
|
" def __eq__(self, other) -> bool:\n",
|
||
|
|
" if not isinstance(other, Cell):\n",
|
||
|
|
" return False\n",
|
||
|
|
" return self.x == other.x and self.y == other.y"
|
||
|
|
]
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"metadata": {
|
||
|
|
"kernelspec": {
|
||
|
|
"display_name": "Python [conda env:base] *",
|
||
|
|
"language": "python",
|
||
|
|
"name": "conda-base-py"
|
||
|
|
},
|
||
|
|
"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.13.9"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"nbformat": 4,
|
||
|
|
"nbformat_minor": 5
|
||
|
|
}
|