EngineHub / CraftBook

🔧 Machines, ICs, PLCs, and more!
https://enginehub.org/craftbook/
GNU General Public License v3.0
300 stars 163 forks source link

3 & 5 bit Random ICs [MC2020]&[MC6020] sometimes have no outputs #715

Closed LadyCailinBot closed 4 years ago

LadyCailinBot commented 10 years ago

CRAFTBOOK-2798 - Reported by jjkrause

I know we already talked about this issue, but I'm just creating an official ticket.

Problem 1: When using the 3 and 5 bit Random generators, I sometimes get no signal on any of the output lines, even when line 3 on the sign reads "1".

Problem 2: If placing 2 Levers on a 3bit Random Generator, I will often get no output as well. Seems like it can still try to output on a lever that is not present. The same applies to the 5bit. (This may be the same as problem 1, but not sure).

Wishlist: Have the possibility of turning off all outputs when the input signal goes low. That way, if the same output is chosen twice/three time in a row, we can still perform some action, even if it was the same actions as the previous cycle (the same output twice or three times in a row happens very often, maybe too often, but I guess that's what randomness is). Maybe adding a "Reset" command on line 4 or some other keyword. This would apply to the 1, 3 and 5bit random generators.

As always, thanks and awesome work.

Jason

LadyCailinBot commented 10 years ago

Comment by jjkrause

Could you also check the code for how it randomizes? I made a game where ic [MC6020] chooses 1 of 5 random colors and makes the floor of that color disappear, but it seemed to choose a certain color way more often then some of the others. See attached pic for the test I ran (not sure about the output numbers but you will understand). I connected the 5bit randomizer to a clock and took note of which output was chosen 200 times. Here are the results:

Output Times

Chosen Percent

0 05 02.5% 1 15 07.5% 2 53 26.5% 3 95 47.5% 4 29 14.5% 5 03 01.5% Tot 200 100.0%

The odds are that each output should be chosen roughly 40 times out of 200, or 20% of the time, but output 1 and 5 are way too low and output 3 is more than double what it should be.... Also note no outputs(0) were chosen 5 times out of 200.

LadyCailinBot commented 10 years ago

Comment by me4502

The computer provides the random numbers. Try testing with realistic randoms off and on in the config, one should give better randoms.

LadyCailinBot commented 10 years ago

Comment by me4502

I've just added a minOn option to the IC.

LadyCailinBot commented 10 years ago

Comment by jjkrause

When I tested I had realistic-randoms: true, which should have given more random results. But I'll test again with True and False and compare results.

Thanks for the minOn option.

LadyCailinBot commented 10 years ago

Comment by jjkrause

Downloaded Craftbook v. 3.7-SNAPSHOT:3346-bf4eec6,master and tested the 3 Random ICs. Some strange results.

[MC1020] 1bit - No longer works for me, I either get solid on, or off.

[MC2020] 3bit No online help for line 3.

[MC6020] 5bit No online help for line 3.

Also, 85+ minOn = Math.min(minOn, chip.getOutputCount()); 86+ maxOn = Math.min(minOn, maxOn); On line 86, shouldn't it read Math.MAX?

Thanks, Jason

LadyCailinBot commented 10 years ago

Comment by me4502

Try the latest build. I fixed the Math.min issue.

LadyCailinBot commented 10 years ago

Comment by jjkrause

Craftbook version 3.7-SNAPSHOT:3347-19feb1d Pretty much the same results as before...

1bit - always on or off depending on minOn:maxOn values 3bit - same as before 5bit - same as before

LadyCailinBot commented 10 years ago

Comment by me4502

Try the latest now. Edit: I can't see any more logic issues, everything else seems flawless.

Edit: Try 3349, not 3348 should fix the 0:whatever issues.

LadyCailinBot commented 10 years ago

Comment by jjkrause

3349 1bit - seems to be working as it should 3 bit - same as before 5 bit - same as before

It almost appears as though the 3 & 5 bit ICs aren't taking the new code. The ingame help doesn't show Line 3: minOn:maxOn either...

LadyCailinBot commented 10 years ago

Comment by me4502

Turns out it was actually still setting that amount.. But it was resetting all the pins every time it iterated over the pins. I've now made it only reset the first time, and only count something that changed from off to on as a change.

LadyCailinBot commented 10 years ago

Comment by jjkrause

With build 3350, the server starts then crashes. See attached log. Tested on a new server with minimal plugins. Doesn't crash when I remove the Craftbook plugin.

LadyCailinBot commented 10 years ago

Comment by jjkrause

Disregard last comment, I created a new world and it is starting correctly.

Results for

5-BIT RANDOM [6020] 2:3

(expected result is either 2 or 3 outputs on every cycle)

Result: Always getting 2 outputs. Also, if for example outputs 2 and 5 remain on for two cycles in a row, only one of the will be reset, so the second one doesn't receive a new pulse.

LadyCailinBot commented 10 years ago

Comment by me4502

With the second thing, could that be directional? Like ones at a certain direction don't? If so, nothing I can do about it; mc has many directional bugs. With the first, if you set it to 1:3, does it choose between 1 and 2? The 3 may be exclusive.

LadyCailinBot commented 10 years ago

Comment by jjkrause

With 1:3 I always either get 1 or 2 outputs, never 3. I'm not sure what you mean about direction... All I have set up is a MC6020 connected to 5 command blocks that "say 1" through "say 5".

Also, if I remove 2 levers on a [6020], shouldn't I still always get at least 1 output because of 1:3? When I remove a lever, I sometimes get no outputs as if its still trying to output to the missing lever...

LadyCailinBot commented 10 years ago

Comment by jjkrause

Ok, I get what you mean by direction. It only seems to happen with the two levers closest to the sign on a 6020.

LadyCailinBot commented 10 years ago

Comment by jjkrause

[MC6020] 3:3, 4:4 and 5:5

Stops my [MC1421]S clock, then crashes the server after a few secs. That's probably why my other world wasn't starting, I had one of those combinations. Infinite loop maybe? CPU fan speeds right up...

LadyCailinBot commented 10 years ago

Comment by me4502

I'll look into that this afternoon. I'm assuming the maximum is exclusive as I guessed before, and due to that the minimum is higher than the maximum

LadyCailinBot commented 10 years ago

Comment by me4502

Try the latest dev build.

LadyCailinBot commented 10 years ago

Comment by jjkrause

3.7-SNAPSHOT:3353

[MC6020] 1:1 -> I get 1 or 2 outputs, should always be 1 output 1:5 -> Always 1 to 2 outputs, should be between 1 and 5 outputs 2:5 -> Always 2 outputs (should be between 2 and 5 outputs) 5:5 -> Crashes server

Of all the tests I've run, I wasn't able to get more than 2 outputs simultaneously.

LadyCailinBot commented 10 years ago

Comment by jjkrause

Also more testing [MC2020] (3bit) 1:1 -> With only 2 levers placed, I will get 0 or 1 outputs. It seems its still trying to trigger the lever that isn't there.

LadyCailinBot commented 10 years ago

Comment by me4502

I'll be able to look into the other stuff in about a week sorry, I'll be without a computer for a week.

Also, the random IC is not supposed to skip missing levers, IC's don't work that way. Edit: I just made them skip the levers, I've got a little bit of time before I leave.

LadyCailinBot commented 10 years ago

Comment by me4502

Using the latest build, I tested the MC6020 IC and it does noy always output 2 for when it's on 2:5, but it seems to prefer 2 a whole lot more than the other numbers. I tried it 100 times and I got 2 for 95 of those times. I made it output to the console for a build and it was outputting that from the actual number generator, so it seems to be an issue above CraftBook.

Edit: Restarted the entire VPS and the randoms are better now.

LadyCailinBot commented 10 years ago

Comment by me4502

Have you tested this more recently?

LadyCailinBot commented 10 years ago

Comment by jjkrause

No, sorry. I've taken a little break while they stabilize Bukkit 1.7.2 and update the plugins I use. I was getting a bit frustrated with all the crashes. ;) I'll get back to it soon...