* How do I flip bit#n in a word variable?
youngdave
Posts: 70
Dear All
* How do I flip bit#n in a word variable?
TIA David Young
* How do I flip bit#n in a word variable?
TIA David Young
Comments
1 << bit makes a 1 bit mask from the bit number you want and it's then XOR'd against your word variable to invert only that specific bit
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lt's not particularly silly, is it?
term.bin(Chromosome[noparse][[/noparse]Current_Population_Size] ^= 1 << (|| rr.random // 16+1),16)
David Young
Your variable names intrigue me. Are you writing a GA for the Prop?
BTW, you can copy and paste your code here, www.phipi.com/format, to convert it to something that displays better in the forum.
-Phil
TIA David Young
The fact that you're matching bit strings leads me to infer that you're using a Michigan (John Holland)-style learning classifier system. Correct?
-Phil
Post Edited (Phil Pilgrim (PhiPi)) : 8/27/2009 2:31:26 AM GMT
Who's John Holland?
TIA David Young
-Phil
Don't want to be too picky here, but Holland simply reinvented genetic algorithms based on the real thing!
Thanks for the PDF. I try to avoid that type of stuff because its not in my language, and I end up confused, rather than than thinking it thru from first principles. But thanks, I'll have a look at it.
TIA David Young