09-26-2015 07:37 PM - edited 09-26-2015 07:39 PM
Hi everyone,
I have tried to understand Altenbach code but it is too hard for me, so I tried to do by myself. However this is what I get.
Should I add another for loop and a replace array?
09-26-2015 08:01 PM - edited 09-26-2015 08:02 PM
@TWRLK wrote:
Should I add another for loop and a replace array?
What is the purpose of the local variable? All you need is place the terminal in its place.
The result of your subtraction is sometimes a negative number. Since there are no elements with negative indices, you won't get anything useful when that happens. Right?
Why are you wiring above the right inner shift register (creating a new tunnel) instead of across it?
10-02-2015 10:15 AM
I corrected my code and it finally works.!!
Can you check it and tell me if I can improve it?
10-02-2015 10:23 AM - edited 10-02-2015 10:51 AM
@TWRLK wrote:
Can you check it and tell me if I can improve it?
You have way too much duplicate code. All your inner loops can be combined into one. All that differs are a few integer math parts and only these would go into a small inner case structure with four cases. There is also no need for local variables.
What's the point of all the hidden wires? Just to confuse the observer? Eliminate them. All you needs ot to wire out from the right-shift register. No need for a seperate output tunnel per loop.
Your diagram constants should be blue, not orange. Do you know why?
As mentioned, you should make the code scalable. Your diagram constants can be derived from the array size, so the code can adapt no matter what the size of the square input array is.
10-02-2015 10:36 AM
Ok thanks for your advice, I will change my code...No, I do not know what is the difference between blue and orange variables. Can you tell me?
10-02-2015 10:56 AM
@TWRLK wrote:
Ok thanks for your advice, I will change my code...No, I do not know what is the difference between blue and orange variables. Can you tell me?
it's the datatype. Blue wires are integers. You would right-click the diagram constant and select represetation...I32.
Also note that your math is incorrect. Sometimes toy are accessing the same element twice in a row. For example after replacing the top four elements, you only need to replace 3 elements going down, three elements going left, and two elements going up. etc.