Skip to content

Commit

Permalink
[2024/6] p1 tidying
Browse files Browse the repository at this point in the history
  • Loading branch information
StarlitGhost committed Dec 6, 2024
1 parent 28cba48 commit 97cc995
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions 2024/6/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@
from GhostyUtils.vec2 import Vec2, Dir


def move(pos: Vec2, dir_: Dir, grid: Grid) -> tuple[Vec2, Dir]:
if not grid.in_bounds(pos + Vec2(dir_)) or not grid[pos + Vec2(dir_)] == '#':
return pos + Vec2(dir_), dir_
def move(pos: tuple, dir_: Dir, grid: Grid) -> tuple[tuple, Dir]:
next_pos = pos + Vec2(dir_)

# out of bounds or open, return next position
if not grid.in_bounds(next_pos) or not grid[next_pos] == '#':
return next_pos, dir_

# obstacle, rotate right 90 degrees
else:
return pos, dir_.turn_right()

Expand Down

0 comments on commit 97cc995

Please sign in to comment.