WilliamHPNielsen / limnos

Other
0 stars 0 forks source link

walls_from_trails location #8

Open jeppetrost opened 3 years ago

jeppetrost commented 3 years ago

walls_from_trails seems like part of the visualisation.

Should this be moved?

Should it even be public? When would the walls ever interest me if not as part of visualising the maze?

WilliamHPNielsen commented 3 years ago

When would the walls ever interest me if not as part of visualising the maze?

Spot on question. To fully answer that, I think we need to agree on what limnos actually generates, as in, what is (the data interchange format of) a maze really? That's probably a separate issue we should open, but I can offer some initial thoughts here.

I think a "maze", the product of limnos, should be some serial format. It may indeed just be a serialization of a Trails object, but it could also be the walls of a maze or something else. We should then have one or more visualisation modules that consume this format instead of an internal non-serial representation (the Trails object itself).

Does this make sense to you, @jeppetrost and @petterbejo?

jeppetrost commented 3 years ago

As I understand, there are multiple Trails representing a single maze, since branches of branches can be swapped. Would a serialization be required to give the same maze or the same Trails object?

WilliamHPNielsen commented 3 years ago

Would a serialization be required to give the same maze or the same Trails object?

I am not sure I understand the question, so let me just stab at it.

It's true that one physical maze can have several different Trails representations, since the order of the branches doesn't matter for the actual maze. Is this what you are addressing? We currently don't have an implementation of __eq__ on a Trails object to check for this equivalence, but that would be a nice thing to implement. And then I guess the serialization would have to preserve __eq__ equality upon deserialization, i.e. (in rough pseudocode)

if trails_a == trails_b:
    assert Trails.deserialize(trails_a.serialize()) == Trails.deserialize(trails_b.serialize())

Does this address your concern/question, @jeppetrost?

jeppetrost commented 3 years ago

It does. One might consider a 'canonical form' of trails where branches are stored eg in a counter-clockwise-first manner. This immediately suggests a __eq__ which compares the canonical forms of the trails.

jeppetrost commented 3 years ago

Or indeed, looping back, one might simply compare the resulting collection of walls!

WilliamHPNielsen commented 3 years ago

Let's continue the discussion in #9. The outcome thereof will decide the fate of walls_from_trails.