Skip to content

Commit

Permalink
[2023/23] use new Dir utils functions
Browse files Browse the repository at this point in the history
  • Loading branch information
StarlitGhost committed Dec 24, 2023
1 parent 514ce77 commit 3a94582
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions 2023/23/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
from GhostyUtils.grid import Grid
from GhostyUtils.vec2 import Vec2, Dir
from functools import partial
import itertools


force_dir = {
'^': Dir.UP,
'v': Dir.DOWN,
'<': Dir.LEFT,
'>': Dir.RIGHT,
}
force_dir = Dir.map_udlr('^v<>')


def passable(current_pos, next_pos, *, grid: Grid, ignore_slopes: bool = False):
Expand All @@ -26,7 +20,7 @@ def passable(current_pos, next_pos, *, grid: Grid, ignore_slopes: bool = False):
travel_dir = Dir(tuple(next_pos - cur_pos))
if grid[next_pos] in force_dir:
forced_dir = force_dir[grid[next_pos]]
if travel_dir is Dir(tuple(-Vec2(forced_dir))):
if travel_dir is forced_dir.flipped():
return False

if grid[cur_pos] in force_dir:
Expand Down

0 comments on commit 3a94582

Please sign in to comment.