I am running Build 132 on Windows 7 Professional, 64-bit.
I have noticed that spark travel speeds are frequently inconsistent. Furthermore, they are also nondeterministic in that saving/reloading the file or saving/loading a stamp changes the behavior.
All path lengths are the same. Note the travel speed differences ultimately leading to unsynchronized firing of ARAYs which should, theoretically, all fire at exactly the same frame.
Also note in the top left the gap in BRAY decay rate.
After the first run, I create a stamp, clear, and paste, then rerun. Note that the pattern has changed. It does so happen that the ARAYs fire at the same time, but things do not usually go so well.
Possibly related to this, occasionally INSTs activate in segments, and do not transfer sparks instantly. I have also observed several situations where sparks were travelling properly, then, suddenly and permanently, the travel speeds changed (and persisted even after file reload, causing me to have to rework electronics to function correctly with the new behavior).
This makes it very difficult to create predictable and reliable electronics (e.g. a reliable SR latch is difficult to implement because a properly functioning one may cease to function after a file or stamp reload).
With the current particle system, electronics(and all reactions) may behave different depending on when the individual particles were created. When a save loads, it creates them from the top left, going right and down, which is different than how a user would have created it manually. It has to do with how the particles are updated, first created to last, and some reactions only transfer instantly (SWCH) if all the updates follow the SWCH's direction, example, a line of SWCH you draw manually going right to left will turn on instantly from the right side, but use the line tool (or save and reload) and it will go slow. This can't really be fixed and it has always been this way, but i think a new saving method (not available yet) will fix the save/loading differences.
So to make something work consistently, make sure you save/load and test a lot.
@cracker64(View Post) True, but in this case there is some SPRK on normal conductors which is behaving inconsistently. And that *is* meant to go at a constant speed. In the video, there's a particle of PSCN in the top half that is sparked one frame before the corresponding particle in the bottom half. Up to that point, the progress of the spark is symmetrical.
I'm having a go at fixing it now. In sprk.c: "(parts[i ].life<3 || ((r>>8)<i && parts[i ].life<4))". I think those conditions may be wrong. It's particle r>>8 that will have a different life value depending on whether it is updated before or after the spark is transferred to it, not particle i.
Thanks, I appreciate you taking a look at it. I also feel that, even with cracker's explanation, the spark travel speed is supposed to be invariant - at least that is my understanding. It is especially important when constructing logic circuits that rely on timings being consistent and as documented.
Also, another weird data point, if I remove the bottom left and top right ARAY+METL pair, then the bottom right ARAY fires only 1 frame behind the top left ARAY, rather than 2. I am not familiar with the game's implementation, but this suggests that the problem may not be dependent on creation order?
Edit: Here is a test save. All paths are equal length, the spark starts in the center of each quadrant and all sparks should terminate at the same time:
Edit: Here is a second manifestation of this problem. This shows inconsistent spark speeds in INSTs, as well as a BRAY being blocked at an empty cell (which may or may not be a related problem):
Two BRAYs should pass through the filters on every cycle (corresponding to the two empty cells in the line of PSTE). The version on the right using INSTs sometimes only has one BRAY come out the other side. There are two things that happen: The ARAY on the right fires one frame before the other four, and also the BRAY sometimes does not pass through the filter when the PSTE moves out of the way in the same frame. I do not know if it is unique to that out-of-sync ARAY on the right or if that can happen anywhere.
Edit: Here is a 3rd example and test case showing this problem causing a failure in practice. These step drivers should advance the BRAY position on each step. All are identical except for orientation. The one on the top left fails and all BRAYs get through at the same time on the first step:
The structure on the right is a somewhat simplified example. Follow the instructions on screen. The one on the bottom right fails and both BRAYs get through at the same time (only one should get through). In just that one case, the SWCH activates on the same frame that the PSCN is hit by the BRAY; in all seven other cases, the SWCH activates one frame after the PSCN.
With that version, all three test cases work for me. Most other saves seem to still work, I would be interested to hear about ones that don't.
@cracker64(View Post) Actually, the new save format won't fix that. Storing coordinates for each particle didn't compress very well, so it does a similar thing to the current format except multiple particles can be in the same place.
Whoa! This works *amazing*. Not only do the three test cases work, but in general everything seems to be happening much more in sync, electronic part and spark timing seem to be spot on all around, and it just feels a lot more predictable. Awesome job, thank you so much.
It even fixed things that I previously thought were just screen update problems, for example:
I had made this to experiment with the invisible wall / sign move bug. I noticed that the top half of the screen always flashed out of sync with the bottom half, but didn't think much of it (it's actually saved that way in the screen shot, as you can see). Now the entire screen flashes at the same time (presumably because of your spark fix).
I was unable to construct a test case that fails but I will keep trying.
It did break the "direct access" version of the memory module in my save here:
Both the base design on the left and the test program on the right fail with the new version, but I believe they *should* fail and once the spark fix makes it into a release I will update accordingly. However, it is an example of a broken save. I have not tried to find the cause of the failure yet, but it also fails without the extra delay I added to the store lines (see comments). The other versions of the memory work fine.
It also broke your 8x6 line text display (which, btw, is one of my favorite saves, and I just now realized that it was yours):
I observed some other odd behavior related to BRAYs passing through FILTs and SWCHs, but I wasn't sure if it was related to this problem or not so I haven't dug into it. That particular behavior is still happening and I will create a new forum thread about it shortly.
So far so good though. I do expect a few of the more electronic oriented saves (computers and games) to break.
Great fix, thanks again. I'll let you know if I find any other cases that fail.
P.S. My third test case actually had some of those invisible walls in it, preventing it from working at all in build 132, I removed them and updated the save.
The single frame delay in "INST fail test" save was because the wifi particles weren't firing at the same time.
Press D to enable debug mode and mouse over a particle. The particle ID will be displayed (top right corner, the number after the '#'). On each frame, there is a loop that updates particles (calculates interactions with other particles and moves particles around) in order of their particle ID.
On the frame when the input wifi particle receives a spark: The top three output wifi particles are updated first. The wifi channel is off, so they do not create a spark. Next, the input wifi particle is updated, and because there is an adjacent spark it turns the wifi channel on. The remaining four output wifi particles are then updated, and because the wifi channel is on they produce a spark.
On the following frame, the top three output wifi particles produce a spark.
The fixed program delays all spark production by wifi until the following frame.
It's based on a newer version of the source code than v70.1, so the sign tool no longer creates walls and the false walls are removed when loading saves.
Sorry about the delayed reply here. Yes, things are working well with the SWCH change reverted. I think you should keep the instant activate left->right SWCH behavior. On one hand, I strongly dislike orientation-dependent behavior for electronics, but on the other hand, there is a lot of value for instant-activate SWCH. It's probably safe to keep this behavior as long as it becomes invariant for future versions.
The only other solution I can think of is perhaps to make SWCH activate instantly when it's tmp is set to 1 or something, but that still changes the default behavior of SWCH and so could break a lot of existing work, and it seems kind of kludgy.
There is another orientation-dependent issue regarding SWCH in ARAY+FILT lines that still occurs even in your spark speed test builds. I've created a post about that issue here.
-C
P.S. Thanks for explaining the WIFI fix. It seem consistent and well-behaved all around now, and IMHO you should keep that change.