Genetic Algorithm on Arduino, Arxiv

Nuno Alves implemented a simple Genetic Algorithm

Our sample optimization problem consists on maximizing
the function f(x) = x on the integer interval [0,31].

Limitations...

? The population size is limited to 100 individuals. This is user specified in main.cpp.
? Each individual has a hardwired 32 bit chromosomes. This means that the solution encoding is constrained by those number of bits.
? The value of each fitness evaluation variable, which states how good a particular solution is, must be between 0 and 100.

more info

Maybe it can be useful for someone!!

Hmm - this is very interesting to me...

I had a friend who once implemented a similar algorithm in a program written in a combination of QuickBasic and assembler for the PC; in the program, he created so many autonomous agents, gave them a task, and then when they completed it (or didn't), had the program "breed" the successful ones (based on some scoring mechanisms; plus he added some random mutation variation as well), and then applied the resulting children to the same task.

He told me - and I am apt to believe him due to what I have seen he could accomplish, when he put his mind to it - that after many itterations of this process he found that some of the agents were performing actions which he hadn't designed in; in fact, the agents were exploiting a loophole (a bug, actually) in his programming; his sequences were longer than 32 bits, and they controlled how the agents worked in the simulated world and tasks he provided (they were essentially virtual "robots" that could move around a grid that had obstacles, food, and such).

One of these "loopholes" was a positional command; rather than moving as a robot, the agents had a evolved to use a loophole that allowed them to "teleport", gaining an advantage over other agents in the system. He also saw (he monitored logs, and had the ability to run the simulation forward and backwards on-screen) that certain agents had learned how to "communicate" by "wiggling" (rotation) and changing their position (more or less "bee dancing"). He hadn't designed this in, it was all evolved over many generations.

At the time he was still in high school, and was running this software on a 286 under DOS. I had already moved to Phoenix, Arizona from our hometown - he originally told me about this at that time. I later learned (when he, too, moved to the Phoenix area - about 10 years later) that when he found the agents teleporting and communicating, he ended the simulation. Not long thereafter his harddrive crashed, and took the sourcecode and simulation with it. He didn't have a backup.

I learned this while I was talking with him for the first time in many years, at the house he was renting; he lives a very bohemian lifestyle, and at that time his "room" in the communal household (which had several members) consisted of a walk-in closet. Computers and electronics in various states of repair/disrepair were strewn about, along with voluminous amounts of trash, detritus, and fast food wrappers. Network cables snaked everywhere along the floors and walls; the glow of monitors lit the rooms in a hazy electric glow at night. It was very "cyberpunkish" in nature.

He let me have a complete copy of his coding archive up to that date; this included many lines of QuickBasic, 80x86 assembler, C/C++, and Visual Basic code (he and his group were working on a large, realtime, multiplayer networked space strategy war game in VB6 coupled with DirectX - it was fast, had excellent graphics and sound, and sadly, was never, ever released). Part of this archive included several of his genetic algorithm experiments (along with several of his gaming and graphic experiments - the guy was not only an excellent coder, he was also a top-notch anime-style artist; fused together, his games were as amazing as anything that came out of Japan - curiously, he wasn't otaku nor identified with that culture), which were fairly advanced. Part of me has a feeling that somewhere in that archive lies his simulation, or at least the ghost of it.

Me and him parted ways a couple of years back; things didn't work out well. I have no idea where he is, whether he is still in the Phoenix area, or what he is doing. Last I knew he seemed to have a mental break with the idea of being a software developer the rest of his life; he may have "gone on sabatical". He is extremely intelligent (he was a member of Mensa from gradeschool thru highschool), in ways I barely understand; with that intelligence, though, comes a touch of insanity, and I think he couldn't reconcile working in the software development field forever, and wanted to do research (sadly, he can't seem to see the disconnect between doing nothing and not being able to pay his bills). I had tried to get him a job at my current employer, he didn't even last out his first day - just went to lunch and never came back, nor did he appologize to me for making me look the fool to my employer and fellow employees. Never again will I make the mistake of recommending a friend to a job...

I think it is great that this has been done for the Arduino, though - I can see creating (an albeit expensive) swarm of robot agents, including the code in the Arduino to control them based on the details in the 32 bit genetic code; applying some form or method to allow them to communicate and "breed", dumping the resulting offspring to a file to be re-uploaded to the next "generation" to allow them to evolve in unknown and unseen ways.

Just watch out for them doing strange things; if you see them teleporting or waggling around "talking" to each other, it might be time to bring out an EMP gun and neutralize the situation!

;D

I think it is great that this has been done for the Arduino, though - I can see creating (an albeit expensive) swarm of robot agents, including the code in the Arduino to control them based on the details in the 32 bit genetic code; applying some form or method to allow them to communicate and "breed", dumping the resulting offspring to a file to be re-uploaded to the next "generation" to allow them to evolve in unknown and unseen ways.

I didn't read quite all of your comment but this jumped out. Maybe it could be implemented on some kind of version of the Illuminato X Machina.
:slight_smile:

Mowcius