Skip to content

Commit

Permalink
[states] Implement is_done() in base class
Browse files Browse the repository at this point in the history
  • Loading branch information
Prometheus3375 committed Jul 17, 2024
1 parent 93d9d00 commit a832e1f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion solve/states/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def is_done(self, /) -> bool:
"""
Whether this state is done.
"""
raise NotImplementedError
return len(self.shapes_to_give) == 0 and len(self.shapes_to_receive) == 0

@property
def shapes_available(self, /) -> Multiset[Shape2D]:
Expand Down
22 changes: 11 additions & 11 deletions solve/states/rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ def __init__(
shapes_to_receive=shapes_to_receive,
)

@property
def is_done(self, /) -> bool:
"""
Whether this room contains exactly 2 different opposite shapes
and none of dropping shapes must be given.
"""
return (
not self.shapes_to_give
and len(drops := set(self.dropping_shapes)) == 2
and drops == shape2opposite[self.own_shape]
)
# @property
# def is_done(self, /) -> bool:
# """
# Whether this room contains exactly 2 different opposite shapes
# and none of dropping shapes must be given.
# """
# return (
# not self.shapes_to_give
# and len(drops := set(self.dropping_shapes)) == 2
# and drops == shape2opposite[self.own_shape]
# )

def pass_shape(self, shape: Shape2D, other: Self, /) -> [Self, Self]:
"""
Expand Down
8 changes: 4 additions & 4 deletions solve/states/statues.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ def __init__(
shapes_to_receive=shapes_to_receive,
)

@property
def is_done(self, /) -> bool:
t1, t2 = shape2opposite[self.own_shape]
return self.shape_held == t1 + t2
# @property
# def is_done(self, /) -> bool:
# t1, t2 = shape2opposite[self.own_shape]
# return self.shape_held == t1 + t2

def dissect(self, shape1: Shape2D, other: Self, shape2: Shape2D, /) -> [Self, Self]:
"""
Expand Down

0 comments on commit a832e1f

Please sign in to comment.