## Help with comparing two lists of two numbers

Mar 14, 2013 at 9:56am

# Help with comparing two lists of two numbers

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′

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’.

– Pasted Max Patch, click to expand. –
#67072
Mar 14, 2013 at 10:02am

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

#241385
Mar 14, 2013 at 12:37pm

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

#241386
Mar 14, 2013 at 12:55pm

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

#241387
Mar 14, 2013 at 12:59pm

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

#241388
Mar 14, 2013 at 1:52pm

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.

– Pasted Max Patch, click to expand. –
#241390
Mar 14, 2013 at 2:45pm

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 !

#241391
Mar 14, 2013 at 5:37pm

– Pasted Max Patch, click to expand. –
#241392
Mar 14, 2013 at 6:10pm

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

– Pasted Max Patch, click to expand. –

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’ ?

– Pasted Max Patch, click to expand. –
#241393
Mar 14, 2013 at 7:48pm

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

#241394
Mar 14, 2013 at 8:17pm

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.

[attachment=217762,5185]

###### Attachments:
#241395
Mar 14, 2013 at 8:45pm

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.

– Pasted Max Patch, click to expand. –
#241396
Mar 15, 2013 at 12:47am

yet another way [p segment]:

– Pasted Max Patch, click to expand. –
#241397
Mar 15, 2013 at 1:13am

and regarding your last question

– Pasted Max Patch, click to expand. –
#241398
Mar 15, 2013 at 8:21am

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

#241399
Mar 15, 2013 at 9:26am

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.

#241400
Mar 15, 2013 at 11:45am

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.

#241401

You must be logged in to reply to this topic.