Wednesday, June 4, 2008

Self-Learning in 2D


A very fast (computing time) self-learning mechanism is here taught the basic behavior of interacting particles such as atoms or molecules. Running on one of the first GHZ Pentiums, even written in BASIC, the model achieved 22500 moves per second. It was written in Visual Basic VB6 with the source code available by emailing for latest version. May in time include here.


Shown below are 500 constantly moving "Bots" as they are called due to their being most like a robot in the way they navigate their environment, after first being introduced to their virtual 2D World.

There is an invisible wall (shown in Red) that contains them. Hitting the wall sets a bit which is used as part of the Address at which each Memory is stored. Bumping another bot already there, is trying to occupy the same space as something already there. Unless this is detected then applied to its learning it will do this. Therefore this is one of the behaviors that must be self-learned for it to successfully model particles which cannot occupy the same space at the same time.

The behavior is defined by this If..Then.. sentence.

If Wall(N) = 0 And Bump(N) = 0 Then CnfChange = 1 Else CnfChange = -1

When not hitting or bumping another the Bot has a positive confidence which can keep rising until it reaches the max of 3. When it goes down to zero it takes a random guess what to do next, until it finds a solution or gives up after 50 guesses in which case it is stuck and cannot move anywhere.After several
hours of training they began to aggregate into groups that together maintain complex motions that more or less allows them to stay in one place.

What it learns is stored in a 65 megabyte array, with one 8 bit byte of data at each memory location. The memory is addressed by combining the environmental conditions that it can sense into a 26 bit number (hence 65 meg required) with the following code. The lowest Environment bits see other Bots around itself, in a 5x5 cube (except four corner location to make more circular) which each Bot updates its position in, every time it moves to a new location. In this way they see the other Bots that are around them.

'Form unique number corresponding to positions of other Bots seen.
E1(N) = Bot3D(Xm + 0, Ym - 1, Zm)
E2(N) = Bot3D(Xm + 1, Ym - 1, Zm)
E3(N) = Bot3D(Xm + 1, Ym + 0, Zm)
E4(N) = Bot3D(Xm + 1, Ym + 1, Zm)
E5(N) = Bot3D(Xm + 0, Ym + 1, Zm)
E6(N) = Bot3D(Xm - 1, Ym + 1, Zm)
E7(N) = Bot3D(Xm - 1, Ym + 0, Zm)
E8(N) = Bot3D(Xm - 1, Ym - 1, Zm)
E9(N) = Bot3D(Xm + 0, Ym - 2, Zm)
E10(N) = Bot3D(Xm + 1, Ym - 2, Zm)
E11(N) = Bot3D(Xm + 2, Ym - 1, Zm)
E12(N) = Bot3D(Xm + 2, Ym + 0, Zm)
E13(N) = Bot3D(Xm + 2, Ym + 1, Zm)
E14(N) = Bot3D(Xm + 1, Ym + 2, Zm)
E15(N) = Bot3D(Xm + 0, Ym + 2, Zm)
E16(N) = Bot3D(Xm - 1, Ym + 2, Zm)
E17(N) = Bot3D(Xm - 2, Ym + 1, Zm)
E18(N) = Bot3D(Xm - 2, Ym + 0, Zm)
E19(N) = Bot3D(Xm - 2, Ym - 1, Zm)
E20(N) = Bot3D(Xm - 1, Ym - 2, Zm)
'Add the motor direction to the number. Two bits each for X, Y.
E21(N) = LMR(N)
E22(N) = LMF(N)
E23(N) = RMR(N)
E24(N) = RMF(N)
'Add unique experience for Bumping and hitting Wall to memory.
E25(N) = Bump(N)
E26(N) = Wall(N)

All of the above Environment bits are turned into a single Address:

MemAddr(N) = E1(N) + (E2(N) * 2) + (E3(N) * 4) + (E4(N) * 8) + (E5(N) * 16) + (E6(N) * 32) + (E7(N) * 64) + (E8(N) * 128) + (E9(N) * 256) + (E10(N) * 512) + (E11(N) * 1024) + (E12(N) * 2048) + (E13(N) * 4096) + (E14(N) * 8192) + (E15(N) * 16384) + (E16(N) * 32768) + (E17(N) * 65536) + (E18(N) * 131072) + (E19(N) * 262144) + (E20(N) * 524288) + (E21(N) * 1048576) + (E22(N) * 2097152) + (E23(N) * 4194304) + (E24(N) * 8388608) + (E25(N) * 16777216) + (E26(N) * 33554432)

It adds them together, in power of twos, to derive a number from 0 to 67108863 that describes what it is sensing from its Environment.

Since 26 bits is a large number of different experiences, it can take days for it to have seen everything. After that, memory changes as it may find a new strategy used what once didn't work.

There is no mechanism for taking one memory at a time, yet the large number of possible memories gives it an experience that changes over time. It may after long get set in its ways, do the same thing over in an endless loop that keeps the bots in the center not hitting each other or the walls. But otherwise, it achieves an experience over time in the process of new sensory information being presented over a long period of time.

At some point there will be a trained memory that can be saved with a new file name, to be used as a read-only to model that behavior. In this example they only have to not hit walls or each other to demonstrate the most basic behavior of this mechanism. But the If..Then.. shown above can be added to, for other behaviors.

Shown below is an electronic schematic circuit of the bot this (group intelligence) version started from.


This 2D vrsion showed that this self-learning mechanism works well for what can best be described as moving particles. With a large number being possible at a time, 3D is now being attempted to model Atoms. At that level, there are a small number of atoms that need to be simulated for it to form any molecule, wjhich reduces number of behaviors needing to be taught to a small a number as possible. With their being trillions of different kinds of molecules, a memory for each one is not even possible. But having a large number of realistic atoms running at a time.

One bot will represent one electron in the outer shell. The shape/size of the confinment space it is trained in, will reflect the actual radius of each atom. The path that the internal bots take, reflect energy state, valence, spin up or down, etc.. Bond sites bots that appear at the surface, conforming to a behavior that makes them attractive to what is in a condition to bond to it.

Photon or electron bombardment would be bots (already seen is behavior) that travel in a straight line that can be captured in the swirl of a group (atom), raising its energy state by it being present in the moving configuration, to at some point be released which brings atom back to the stable ground state.

No comments: