Sunday, June 29, 2008

Particle In A Box Bots, Self-Learning 3D Lab with Visual Basic source

Virtual particles in a box are here shown coalescing into swirling entites where sometimes photons can be ejected out of orbits to become like a photon, or be in the form of a visibly oscillating wave with a frequency that depends on shape of the orbital. This program is actually beginning to model what it is that makes matter itself possible!



The zip file has all the files including including ParticlesInABoxBots.exe that will run on Windows PC just by clicking on it so you don't need Visual Basic to try it.
-
-
The code is in ParticlesInABoxBots.frm but begins with code that describes what's on the form like command buttons and picture box it draws in, with the Main Loop that everything happens in, at the very end of the file to be easy to find.A trained memory is not included due it being 16 megs which even zipped is too big to be worth waiting for. Have to wait a few days or more to even know what fully trained might be like, all that is known for sure is that what has been seen so far is awesome. And half the fun is in seeing the particles self-learn particle motion, which would not be seen happen if the program then started up fully trained. Would not display the many behaviors that can be trained into it, that are shown along the way sometimes by accident. For example what happens when unstable but still holding orbital configurations all at once fly apart ejecting each other into everything else for a major fission reaction that has all of them full speed bouncing from wall to wall over and over again and straight line at each other the chaos in the middle slows down projectiles trying to get through an increaingly swirling mass that in a sense swirls itself back to orbitals then it all goes relatively still again.
Might be that how they end up, reflects our personality. Someone aggressive might take their frustions out on the particles by sqeezing them in a world size so small they're like in an infinite horse power trash compactor. While some who are very peaceful might give them plenty of room so they make nice freeful orbits, not ones that look all squished.

A particle such as an electron would not be randomly bouncing off the walls or moving in regular straight lines. Be impossible to say for sure where it is, but what it is shaped like can still be mapped out as in Schrödinger's equation by showing where the probability of finding an electron in orbit would be, by drawing dots where it more likely to be at any given moment. From that these drawings are made showing orbital shapes like these.



Wikipedia helps say in their page on atomic orbitals that these pictures do not accurately depict reality, where the orbits are being stretched, bent and twisted all the time. And there are electrons being shared sometimes in very complex and like in metals constantly flowing around in an organized chaos. The Particle In A Box Bots learn this organized chaos. Not by crunching Schrödinger's equation. The particles self-learn the behavior of particles in motion. All of the complicated math governing motion of particles in 3D space, is this in the start of the RunMotors subroutine with these three equations:


Xm = Xbot(N) + YMF(N) - YMR(N)
Ym = Ybot(N) + XMF(N) - XMR(N)
Zm = Zbot(N) + ZMF(N) - ZMR(N)

Xm,Ym,Zm is the variable the calculation is first being stored in. The X,Y,Zbot(N) is it's current location in 3D cube. The other two variables in each of the three equations end up adding or subtracting one, or doing nothing. Since there are 3 axis in the 3D system Motor Forward and Reverse bits X,Y,ZMF(N) and X,Y,ZMR(N) are either a 1 or a 0. Stopped is when both are either a 0 or a 1 because 0-0=0 and 1-1=0 so either way the current bot location remains unchanged. Direction is then a matter of whether it was 1-0=+1 or 0-1=-1 and since it exists in a on a grid like array the fastest an ejected electron (photon) can travel in such a virtual reality is exactly 1 or -1 which makes the math in this case easy to remember. Since there are two codes to stop the motor, either 00 or 11, the 11 can be used for the bot to do something instead of stop. I am not sure what use it might have, but otherwise, having two codes for Stop is an unnecessary waste of a good amount of memory space. And you can't make a 3 code Forward-Stop-Reverse with less than two bits without compressing all three axis which total bits, into 5 bits, which helps save memory but the 5 bit is not used up either so there is still wasted space. Is best to look for something in the physics of particles in motion where there is something in addition to Forward-Stop-Reverse to hook up to it. The Memory Address that it hooks in to, is shown below.

Private Sub FormMemoryAddress(N As Long)
Addr(N) = XMR(N) + (XMF(N) * 2) + (YMR(N) * 4) + (YMF(N) * 8) + (ZMR(N) *
16) + (ZMF(N) * 32) + (Wall(N) * 64) + (At1 * 128) + (At2 * 32768) + (Greater2 *
8388608)
End Sub

Setting XMR() and XMF() both to 1 whenever the condition to be added is detected, brings it into the Address, which by nature of it always changing in response to environment, can be thought of as generating a sequential experience of one memory at a time. Yet there is no counter to count through each experience one frame at a time, it's in the environmental sensors constantly changing. Even though this is a simple model with a modest one byte per address 16 megs of memory space it's surprising how long it will go on forming new memories. It has nothing in comparison to the number of networked neurons in a brain, but the 24 bit Address space the PC uses, results in a very large number of experiences. That's about 6 days at 32 frames per second, not counting confidence changes and trying something new with a new guess in response to confidence in a memory declining to zero.

And even though to some, the entities formed inside the 3D cube might look more like another Flying Spaghetti Monster Sighting, it has the Particle In A Box analogy right down to infinitely impenetrable. Can either stick, or bounce off. The Wall(N) bit which is 1 when hitting, 0 when No Wall, has to be included in the Address to prevent particles from turning into forever flashing red circles that never go anywhere after that. With the Wall(N) bit included in the memory addressing, a unique Data byte for every time that happens, is there to be taken in response to it. The Environmental Input influences the Action Output then back again in a way that it stimulates its own learning.
Each particle senses up to 2 other particles around itself in 1 of 250 locations inside a spherical field as shown below.



Even though looking at this much of an array space on each move is a slow process with Visual Basic in comparison to what is fastest, he program can still do a good number of particles at a time. You will have to keep the number down to how fast your computer and graphics are or it can become very slow. Large numbers meant to run without trying to draw it to screen. Visual Basic is ideal for showing how this self-assembly works, but will need to rewite in MASM32 to go as fast as a CPU can go, which should be around 1000 times faster. Is still fast enough, even a surprise Visual Basic does as well as it is, even if it's then in the future possible to go much much faster. You can save your own BotMemory.bot memory file so the program will load what you trained, before starting back up again. Rename or delete BotMemory.bot if you later want to retrain the Particle In A Box Bots from scratch all over again.

-

2 comments:

Woloda said...

hi, very interesting articles on your site for me, let's forget I was lookin for self learning bot related to aiml specification. Hovever the link for download particlesinaboxbots.exe is not working

Gary Gaulin said...

Thanks Woloda!

The downloads went offline when AOL ended their FTP service. They are now back online via Google servers, that I hope will take better care of them.