I'm trying to simulate a chain reaction.
My program is not ready at all, it contains bugs in the current state and many more things need to be added, but it can already be tested, and I found a weird problem. I'm trying to plot a grid of atoms among which a particle is passing by, of which route has to be plotted, so I want to plot a straight line. Instead, I get a step-like figure. What could be the problem?
I attached a screenshot of the plot of the theoretically straight line.
You have 90% too much code. Overly complicated!!!
Your graphs are in integer datatype and later wiring a DBL array to a local variable does not really change any of that.
Have you looked at all at my earlier example? All you need is an xy graph with three plots (one for the red diamonds, no interpolation, one for blue square, no interpolation, one for the particle).
To determine even/odd, just bitwise AND with 1 and see if the result is zero. No need for a formula node!
NONE of you local variables are needed!
Thanks again for your answer, you are helping me a lot!
I can't use only 3 plots (one for the red, one for the blue points, and one for the particle trace), as every time a particle hits a point (an atom), I have to color it grey, so I will have to constantly change the color of the particles automatically during the simulation. So that's why I use a plot for every single point, so that I can set their colors one by one. The %2 coloring was just a test to see whether this method works or not.
And how could I plot the particle's trace as a straight line? You said that the XY Graph's datatype is integer, how can I modify that?
So you need four plots. Red, Blue, Grey, (all dots) and white (line))
When a dot gets hit, just move that point to the grey plot (or just add it to the grey plot and it will cover the original colors if you keep the plot order correctly)
Here is a very simple example that shows a red grid, adds a random line, then colors all grid points "close" to that line grey. Code literally fits on 1/4 postcard! No local variables!
(Note that the first plot is on top,)
Maybe it can give you some ideas how to do it better. Modify as needed. You never need more plots than different colors.
Another option would be to use a picture indicator. Maybe preferable?
Thank you for your help! Really, you don't even know me, but your help has been incredibely important 😄 The task I'm working on was a university task. I had a class where we were writing simple LabView programs, but really just the simplest ones, and then the teacher gave this homework... So it's not a surprise I got stuck sometimes. I'm close to finish the project, but I still have one problem. My program is almost working fine, a particle starts at a random place, if it hits an atom, it vanishes and produces two new particles, which then hit other atoms, and so on, the chain reaction is ready. If an atom leaves the grid, it vanishes, too. But after some time, the problem suddenly stops working, the particles stop, but the program runs in the background, as if it would be in an infinite loop. Do you have an idea where the problems occur?
You again have way too much code. All you need is a single outer while loop and a state machine architecture. No need for local variables. Use "built array" (not insert into array) to append or prepend an element to an array. Properties only need to be written when the property value changes, not with every iteration of the loop. etc.
Thanks, I will try to implement your suggestions. But what do you think the reason is for the stop during simulation?