aroberge / reeborg

Enhanced Karel-the-robot clone
http://reeborg.ca/reeborg.html
Other
47 stars 36 forks source link

Box missing for Sokoban #457

Closed abixadamj closed 3 years ago

abixadamj commented 3 years ago

In documentation there is a Box - https://reeborg.ca/docs/en/reference/objects.html used in Sokoban excerise. But in obstacles there is no Box... @aroberge - do you know maybe something about it?

Zrzut ekranu z 2020-11-17 18-46-14

aroberge commented 3 years ago

Sorry about that. I started working on an enhanced version where one could define their own transformation using code, so as to give more flexibility. I remember removing boxes at that time (which had hard-coded interactions) so that they could become more versatile, but never completed the work.

You can find some information about what I intended to do here: https://aroberge.gitbooks.io/reeborg-s-world-advanced-world-creation/content/extending/automatic-transformations.html ... however, the code there does not work.

Something like the following seems to work:

def redefine(fn): def wrapper(): fn() recording_state = recording(False) x, y = position_in_front() if ( RUR.is_pushable("box", x, y) and RUR.is_obstacle("water", x, y) and not RUR.is_bridge("bridge", x, y) ): RUR.remove_obstacle("water", x, y)
RUR.remove_pushable("box", x, y) RUR.add_decorative_object("water", x, y) RUR.add_object("bridge", x, y)
recording(True) RUR.record_frame() return wrapper

move = redefine(move)

RUR.add_pushable("box", 2, 1) RUR.add_obstacle("water", 3, 1) move() move() move()

= = = For sokoban, simply using RUR.add_pushable("box", x, y) should work.

abixadamj commented 3 years ago

@aroberge - SUPER !!!!! It WORKS Zrzut ekranu z 2020-11-21 19-00-21