Help with comparing two lists of two numbers

chapelier fou's icon

Hi,
it must be pretty basic, but i don't know which way to go...

1. how can i output a bang when a list is '0 0' ?

2. Then i need to output a bang in these particular cases (x is non-zero) :
- when '0 -x' occurs after '0 x'
- when '-x x' occurs after 'x -x'
- when '-x -x' occurs after 'x x'
- when '-x 0' occurs after 'x 0'

Max Patch
Copy patch and select New From Clipboard in Max.

Thank you so much...
i wanna use it in this patch. Look at the 'p chemin', it draws a vectorial random path into the lcd. But i want to avoid succession of value pairs that make it go 'backwards'.

chapelier fou's icon

for 1. zl compare 0 0
Sorry, slow brain...

Wetterberg's icon

yeah, zl compare in conjunction with [abs] should allow you to test for all these cases.

chapelier fou's icon

Thanks,
i forgot to mention that x can be positive or negative.

chapelier fou's icon

Hum, i guess i just need to multiply both numbers by -1, pack the results, and compare the two lists...

Jeremy's icon
Max Patch
Copy patch and select New From Clipboard in Max.

This is pretty brute force, but it works. Best, Jeremy

chapelier fou's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Thank you very much Jeremy. Unfortunately it doesn't really work. Maybe because you're assuming that x is a positive number ?
I've made this with only zl compare, it behaves as expected (never go backwards, never stays unmoved) but from time to time, it draws a double segment. Can't figure out why... need a rest i guess.

chapelier fou's icon

Well, a few minutes clicking showed me that my method is also buggy. i guess i just need to leave it until tomorrow.
Feel free to take a look though !

ak's icon
Max Patch
Copy patch and select New From Clipboard in Max.

how about this one:

chapelier fou's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Thank you. It does work indeed. As this one (even with 0 0)

Max Patch
Copy patch and select New From Clipboard in Max.

So this is not a problem with spotting the unwanted lists. It's a patching problem...
So if anyone could look at what's wrong in the 'p chemin' ?

chapelier fou's icon

@Andrzej : for some reason, using your approach in my patch leads to even more 'double' (or even triple and quadruple) segments... i'm lost.

ak's icon

my advice: clean up your patches. It's hard to tell what's going on looking at messy patchers. I did some cleanup for you, and look at blue [pack] – you don't filter out wrong coordinates, everything goes to (line) message. If your algorithm detects wrong data it draws next values (X/Yoffset), and they also can be wrong... but everything is drawn on LCD. Forth and back.

5185.Zrzutekranu20130314o21.01.30.png
png
chapelier fou's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Thank you very much...
I've come to a totally different approach. This is much clearer. No double segment anymore, but still goes a step backwards from time to time.
I now need to find a way to fix it in the 'p segment' : on the random output, i need to avoid 2 when previous was 1, 1 when previous was 2, 4 when previous was 3, 3 when previous was 4.

ak's icon
Max Patch
Copy patch and select New From Clipboard in Max.

yet another way [p segment]:

ak's icon
Max Patch
Copy patch and select New From Clipboard in Max.

and regarding your last question

chapelier fou's icon

Wow, thank you very much ! i really need to learn these logical expressions. It's getting much better. Although my algorithm is not perfect : it still goes backwards from time to time, when after a bang to re-pick a random number, it choses the same again. I think i can live with it, it adds a 'mistake' factor in the maze.
Thank you again.
louis

jvkr's icon

When it is the case that the limitations are larger then the (random) possibilities, it might be much easier to describe those possibilities (requiring much less programming). The problem can basically be reduced to: given the previous step, there are either four or five choices for the next step. There is not much required to put this in a probability table. You might want to take a look at the prob object.

chapelier fou's icon

for sure i will! thanks for the advice. Amazing how an apparently 'simple' thing can require a lot of knowledge and wisdom. Developing programming skills is a very long process i think.