partyrobotics / bartendro

GNU General Public License v2.0
170 stars 89 forks source link

Pump id assignment has frequent clashes #88

Closed mayhem closed 10 years ago

mayhem commented 11 years ago

Ray says:

By the way, I think you're picking random numbers for each dispenser ID during programming? About 1/2 of the time programming a set of B15 dispensers, they'd hit conflicts of duplicate IDs. I know this isn't very intuitive, but it's a variation of the birthday paradox ( http://en.wikipedia.org/wiki/Birthday_problem ) . Long math story short, if you pick 15 random numbers from a range of 255, there's a (15 * 14 / 2) / 255 percent chance that you'll get duplicates. Or about 41%. I had one B15 with 4 duplicates, which was amusing.

mayhem commented 10 years ago

I've implemented a monotonically increasing number now that should have a lot fewer clashes. :)