RALLY E (Help me, internet)

Share

So I’m writing a basic genetic algorithm using bit strings of length 16. I’m getting a weird error where some of my strings have an uneven number of 0s and 1s (and that’s after the check that I’ve built in, which always successfully corrects them). So I do a bunch of tests and fiddle around with print statments, and suddenly I find it. It is the stupidest bug I’ve ever seen my life. Stupider than june bugs, and — considering that at least 200 of them commit suicide in our lamps every year — that’s saying something.

So here’s the bug: for some reason, before and after a mapcar I’m getting this one string mysteriously changed every time. It is the same g*sh-d*rned string every single g*sh-d*rned time. Despite the fact that everything is completely random, if the string “(1 0 1 1 0 0 1 1 1 0 1 0 1 0 0 0)” is EVER generated then the mapcar FOR SOME HORRIBLE REASON THAT DEFIES MY IMAGINATION changes it to “(1 0 1 1 0 0 1 0 1 0 1 0 1 0 0 0).”

So before the mapcar it says:

(1 0 1 1 0 0 1 1 1 0 1 0 1 0 0 0)

But if I call it within the mapcar it says:

(1 0 1 1 0 0 1 0 1 0 1 0 1 0 0 0)

And once it’s spit out by the mapcar it is FOREVER CHANGED INTO THIS HORRIBLE STRING THAT HAS MORE ZEROS THAN ONES AND BREAKS MY ALGORITHM.

* weeps *

Seriously, if anyone knows what on earth is going on and can tell me, I will take you to Burger King. (That means you, Riz!)

PS: I’m sorry for yelling.

PPS: Turns out it does the same thing to a number of strings:

(1 0 1 1 0 0 1 1 1 0 1 0 1 0 0 0)
(1 0 1 1 0 0 1 0 1 0 1 0 1 0 0 0)

(1 0 0 0 1 1 1 0 1 0 0 1 1 1 0 0)
(1 0 0 0 1 1 1 0 0 0 0 1 1 1 0 0)

(1 0 0 1 1 1 0 0 1 1 0 1 0 0 0 1)
(1 0 0 1 1 1 0 0 1 1 0 1 0 0 0 0)

In later generations I sometimes get variants of the first error:

(1 0 1 1 0 0 1 1 1 0 1 0 1 0 0 0)
(1 0 1 1 0 0 1 1 1 0 1 0 1 0 0 1)

Flips from 0 to 1 only seem to happen in later generations.

And it doesn’t do it to them all the time. Ideas?

Share

Comments 7