mirror of
https://github.com/maoakeEnterprise/amazing.git
synced 2026-04-28 16:04:35 +02:00
commit before uv rework
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
install:
|
||||
pip install -r requirement.txt
|
||||
|
||||
run:
|
||||
python3 a_maze_ing.py config.txt
|
||||
|
||||
debug:
|
||||
pdb python3 a_maze_ing.py config.txt
|
||||
|
||||
clean:
|
||||
rm -rf __pycache__ .mypy_cache
|
||||
|
||||
lint:
|
||||
flake8 .
|
||||
mypy . --warn-return-any --warn-unused-ignores --ignore-missing-imports --disallow-untyped-defs --check-untyped-defs
|
||||
|
||||
lint-strict:
|
||||
flake8 .
|
||||
mypy . --strict
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
pydantic
|
||||
numpy
|
||||
flake8
|
||||
mypy
|
||||
@@ -0,0 +1,59 @@
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class Cell(BaseModel):
|
||||
value: int = Field(ge=0, le=15)
|
||||
|
||||
def __str__(self) -> str:
|
||||
return hex(self.value)
|
||||
|
||||
def set_north(self, is_wall: bool) -> None:
|
||||
if (is_wall and self.value | 14 == 15) or (
|
||||
not is_wall and self.value | 14 != 15
|
||||
):
|
||||
self.value = self.value ^ (1)
|
||||
|
||||
def get_north(self) -> bool:
|
||||
return self.value & 1 == 1
|
||||
|
||||
def set_est(self, is_wall: bool) -> None:
|
||||
if (is_wall and self.value | 13 == 15) or (
|
||||
not is_wall and self.value | 13 != 15
|
||||
):
|
||||
self.value = self.value ^ (2)
|
||||
|
||||
def get_est(self) -> bool:
|
||||
return self.value & 2 == 2
|
||||
|
||||
def set_south(self, is_wall: bool) -> None:
|
||||
if (is_wall and self.value | 11 == 15) or (
|
||||
not is_wall and self.value | 11 != 15
|
||||
):
|
||||
self.value = self.value ^ (4)
|
||||
|
||||
def get_south(self) -> bool:
|
||||
return self.value & 4 == 4
|
||||
|
||||
def set_west(self, is_wall: bool) -> None:
|
||||
if (is_wall and self.value | 8 == 15) or (
|
||||
not is_wall and self.value | 8 != 15
|
||||
):
|
||||
self.value = self.value ^ (8)
|
||||
|
||||
def get_west(self) -> bool:
|
||||
return self.value & 8 == 8
|
||||
|
||||
|
||||
def main() -> None:
|
||||
c = Cell(value=1)
|
||||
print(c.get_north())
|
||||
c.set_north(True)
|
||||
print(c.get_north())
|
||||
c.set_north(True)
|
||||
print(c.get_north())
|
||||
c.set_north(False)
|
||||
print(c.get_north())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user