Skip to content

Commit

Permalink
[states.rooms] Add state links to PassMove
Browse files Browse the repository at this point in the history
  • Loading branch information
Prometheus3375 committed Jul 20, 2024
1 parent d448b3c commit 3585d10
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions solve/states/rooms.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@
from ..shapes import Shape2D, Shape3D


@dataclass(frozen=True, kw_only=True, slots=True)
class PassMove:
departure: PositionsType
shape: Shape2D
destination: PositionsType


class RoomState(State):
__slots__ = 'dropping_shapes', 'final_dropping_shapes'

Expand Down Expand Up @@ -96,6 +89,16 @@ def pass_shape(self, shape: Shape2D, other: Self, /) -> [Self, Self]:
return new_self, new_other


@dataclass(frozen=True, kw_only=True, slots=True)
class PassMove:
departure: PositionsType
shape: Shape2D
destination: PositionsType
# States AFTER move is done
departure_state: RoomState
destination_state: RoomState


class StateOfAllRooms(StateWithAllPositions[RoomState, PassMove]):
__slots__ = ()

Expand All @@ -117,7 +120,13 @@ def next_states(self, /, is_doing_triumph: bool) -> Iterator[Self]:
for shape in s1.shapes_available:
if s2.is_shape_required(shape):
new_s1, new_s2 = s1.pass_shape(shape, s2)
move = PassMove(departure=s1.position, shape=shape, destination=s2.position)
move = PassMove(
departure=s1.position,
shape=shape,
destination=s2.position,
departure_state=new_s1,
destination_state=new_s2,
)
kwargs = {
s1.position: new_s1,
s2.position: new_s2,
Expand Down

0 comments on commit 3585d10

Please sign in to comment.