Author Topic: Darwinbots replacement/clone  (Read 20225 times)

Offline Numsgil

  • Administrator
  • Bot God
  • *****
  • Posts: 7742
    • View Profile
Darwinbots replacement/clone
« Reply #15 on: April 09, 2010, 02:55:59 PM »
Quote from: Pascal666
Quote from: Sammeh
What kind of FPS are you getting at say, a population of 1000 bots?
What kind of FPS would you get in DB2 with the same pop?
I am running 200 bots at about 240 cycles per second, while in darwinbots I am running only 50 bots to reach this speed.

I know Eric did a lot of work to make it faster for large( r) numbers of bots.  If you jack it up to 1000, what sort of speed do you get?  Unless you've done some broadphase work it should go way, way down since you're doing some O(n^2) work (so you're doing 25 times as much work at 1000 bots as at 200 bots.  Which means I'd guess you're getting 1 cyc/sec at 1000 bots, where DB2 might get 2 or 3).

Not that what you have isn't impressive, just saying that how many bots you can run at 240 cyc/sec might not be the best metric for comparison.

Also, I should be able to set up SVN this weekend.  If you like, I can set you up with a SVN repo for your code.  Or failing that, you should set up a google code project or a sourceforge project.
« Last Edit: April 09, 2010, 04:12:39 PM by Numsgil »

Offline Pascal666

  • Bot Neophyte
  • *
  • Posts: 25
    • View Profile
Darwinbots replacement/clone
« Reply #16 on: April 10, 2010, 06:31:10 AM »
Quote from: Numsgil
Quote from: Pascal666
Quote from: Sammeh
What kind of FPS are you getting at say, a population of 1000 bots?
What kind of FPS would you get in DB2 with the same pop?
I am running 200 bots at about 240 cycles per second, while in darwinbots I am running only 50 bots to reach this speed.

I know Eric did a lot of work to make it faster for large( r) numbers of bots.  If you jack it up to 1000, what sort of speed do you get?  Unless you've done some broadphase work it should go way, way down since you're doing some O(n^2) work (so you're doing 25 times as much work at 1000 bots as at 200 bots.  Which means I'd guess you're getting 1 cyc/sec at 1000 bots, where DB2 might get 2 or 3).

Not that what you have isn't impressive, just saying that how many bots you can run at 240 cyc/sec might not be the best metric for comparison.

Also, I should be able to set up SVN this weekend.  If you like, I can set you up with a SVN repo for your code.  Or failing that, you should set up a google code project or a sourceforge project.
In AEvolution I get 10 cycles per second at 1000 eye carrying bots, and in darwinbots I get 2 cycles per second with simple algae bots. So the comparison is about the same.
But you could get even a bigger advantage if you run multiple environment/simulations, 2 simulations of 500 bots run at 20 cps/40 total.

These are the main performance checks, which probably could also be applied to darwinbots.
- Colission checks(the 200 stands for the maximum mass which is 100, 100 + 100 = 200...)
For i = Entity + 1 To GLO_TOTALENTITIES ' It doesnt check indexes below him, because they have already checked for colission.
If Entities(i).X - .X > 200 Or .X - Entities(i).X > 200 Or Entities(i).Y - .Y > 200 Or .Y - Entities(i).Y > 200 Then GoTo nextEntity
- Also resizing the index of GLO_TOTALENTITIES to the last highest index of dead entities in main loop.
- And reproduce/repopulation uses the lowest last dead index if there is one.
- DNA gene caching, store the locations of every gene which allows skipping genes faster once the condition is false.

Next week I will create a souceforge project.
« Last Edit: April 10, 2010, 07:05:00 AM by Pascal666 »

Offline peterb

  • Bot Destroyer
  • ***
  • Posts: 148
    • View Profile
Darwinbots replacement/clone
« Reply #17 on: April 14, 2010, 02:07:59 PM »
i think your using vb6 drawing routines (based on the patern fill), these are slow, you might take a look at opengl slimDX or directX.
The fasted method might even be to not draw circles, but XOR bitmap of circles (having a few bitmap sizes in cash doesnt take much memory, or simply stretch)
Faster drawing methods will improve the speed even more.

But i dont think it works for me, not much happens when i load it.
Still i hope your code is more transparent i have given up trying to understand the original code, to much hidden variables for me to keep track off.

If your program is good structured and clear to read.
Then that would be promising.

If possible i would request more memory slots per cell, so we might later introduce real neural networks, and add some extra bot DNA math for that (sigmoid summAll etc, summWeighted).
A multibot editor (to create bots without defining complexly their shape trough DNA) would be nice too.

Offline ashton15

  • Bot Builder
  • **
  • Posts: 99
    • View Profile
Darwinbots replacement/clone
« Reply #18 on: April 14, 2010, 02:36:42 PM »
Yeah i'm having problems with too few memory locations but i've worked out I can store multiple values in one location through a system like binary for instance so 1,1,0 might equal 6 or 2,1,0 with 3 bieng the highest posible value I'd have 63 (0*3 + 1*9 + 2*27) bit too complicated for my liking... also having a small bot circle allows an extra 22 memory locations using every memloc and out sysvar though it's not that practical as it just converts one memory location into another type that in most situations is less useful about twenty-five thousandish should be adequate to create a multi-cellular DB with human intelligence... and maybhe 400 out and in sysvars... is a neural net the same thing as having a web of what varibles every other varible alters? because that's the kinda thing I'm trying to make... I want a bot that can understand that shootval is log2 and changing it affects how far or how powerful a shot is and then that links to a formula somewhere that knows how much it should decrease shootval by because it knows that's what it has to do in order to hit an enemy and thus get energy... it doesn't just do things without thinking... that's the main problem I have with darwinbots. anyways I tried it and made this though it doesn't apear to work

condition
   readmybmem1 1 =
gene
   3 moveforwards
endgene

condition
   sight 999 <
   sight 1 >=
   samespecies 0 =
gene
   refvelocity + 3 moveforwards
   refangle setangle
endgene

condition
   mymass - bondmass 1 >
gene
   sharebmass
endgene

condition
   mymass bondmass >
   myenergy - bondenergy 250 >=
gene
   250 sharebenergy
endgene

condition
   sight 50 >
gene
   1 eat
endgene

condition
   totalbonds 0 =
   samespecies 0 =
gene
   1 writebmem1
   growbond
endgene

condition
   readmybmem1 0 =
   totalbonds 1 =
   myenergy 500 >
gene
   growbond
endgene

condition
   readmybmem1 0 =
   totalbonds 2 =
   myenergy 1500 >
gene
   growbond
endgene

condition
   myenergy 5000 >
gene
   reproduce
endgene
« Last Edit: April 14, 2010, 04:24:19 PM by ashton15 »

Offline Ammeh

  • Queen of the Internets
  • Bot Destroyer
  • ***
  • Posts: 169
    • View Profile
Darwinbots replacement/clone
« Reply #19 on: April 14, 2010, 03:09:00 PM »
looking at the DNA for your bots, it seems they're similar to DB's bots. Could you maybe replace the dna commands to be compatible with DB code?  

Offline peterb

  • Bot Destroyer
  • ***
  • Posts: 148
    • View Profile
Darwinbots replacement/clone
« Reply #20 on: April 14, 2010, 03:49:16 PM »
in simple neural nets can be seen as a layer of dots (memory locations)
most often you see 3 layers of just a few dots
draw lines between dots and call them weights.

so a single dot on the second row does do (sum each dot in the row above (and for each dot .multiply its input with its weight line).
Depending on the results of single a neuron it adjusts the weights. (is it always wrong, then they become close to zero, is it oposite they become negative).
In the beginning the neural net is randomly seeded with random numbers, sigmoid calculations are done to balance the network.
And then with some hope and some clever thinking we might get it into DB  (currently i've seen no sample of a bots using sigmoid functions, some claim to have but i doubt them)
here a not to complex read http://arxiv.org/ftp/cs/papers/0308/0308031.pdf

There are several ways how it can work (and this would be something we have figure out (comparable to evolving zerobots)..
As you can imagine all weights and all dots can compare lots of memory, so to keep the program fast i think not all cells do require such large amounts of memory.


Back to neural nets.
Normally  this math works wit real numbers (maybe floats) and rarely with short integers (maybe an int type is enough). ..
 types >>

As you might notice this requires some memory so it would be better to have another cell type (so not all of the cells would require large amount of memories)
So a brain cell can contain more code, and process more advanced commands.
Also eye cells and movement cells, shooting cells, posion storage, shell cells.. could be smaller (and simply have input or output, and some energy demands and a connection(location?).
I know thats radical different from DB in which a single cell can do everything, and has potentially all kind of information even if it doesn't process them.

Note for all the things that could be done with 1 or 0 you can use binary math (XOR OR AND etc) and so limit memory usage of them.
Although one bit can store only on /of 2 bits can store (00 01 10 11) for states (4 =  2^2  and 3 bits can store  2^3 = 2*2*2 = 8 states.
By us


In DB there areas are like the *.970 area (given to child by birth). (to keep children learn), something like that should also apply i think (so you get spock like brain transfers at birth).
The easist way might perhaps be to have a cell type wit a double adres range, one that is not poluted with all kind of commands



Note the math required actualy for doing this and the training of the neural net, is something which is another topic and a chalange like numsgill chalange for a zerobot using conditional behaviour.

But once we got a small neural network working, it can be exanded..>effectivly becoming smarter.
At ofcoure higher energy costs, as our brains consume the most our bodies energy..

Dont think of to complex neural networks for a starter a single bot with 3 layers and 20 dots  totall, a minimum would be i think about (maybe first layer 5 next 3 next 4   >> 12 dots)
It doesnt require like 50 dots, because also the braincells could be connected to other brain cells.

Another method could be single neuron cells, but then we would require something like a species editor, to connect each cell correctly to make a neural network.
That way they consume less memory but bot creation becomes a new topic of discusion i mean how to do it in DNA, or do it without DNA ?..string discription of species maybe... ??..
« Last Edit: April 14, 2010, 03:55:31 PM by peterb »

Offline Houshalter

  • Bot Destroyer
  • ***
  • Posts: 312
    • View Profile
Darwinbots replacement/clone
« Reply #21 on: April 14, 2010, 07:24:21 PM »
I'm a bit lost reading that   Wasn't the purpose of DB to avoid using neural networks? What we need is a good "read" command so that we can use memory like an array. Theres a store, but no read.

Offline ashton15

  • Bot Builder
  • **
  • Posts: 99
    • View Profile
Darwinbots replacement/clone
« Reply #22 on: April 15, 2010, 07:22:36 AM »
Quote from: Houshalter
I'm a bit lost reading that   Wasn't the purpose of DB to avoid using neural networks? What we need is a good "read" command so that we can use memory like an array. Theres a store, but no read.

By read do you mean * like *.eye5 reads .eye5 or .eye5 * or *505 or even 505 * it's pretty easy to read a single value, and for multiple memory locations you have things like the stack and duplicate commands... would probably help a lot if you could read various positions in the stack if that's what you mean... or do you mean having multiple stacks... I'm slightly confused by what you mean.

As for the neural network I'm trying to create something which looks at every varible and tracks which ones change when another changes and draws "synapses" between them and some varibles are read only but can be adjusted by other varibles and the goal of the robot is to boost these varibles as high as possible through the manipulation of writing varibles and then occasionally a string of random DNA is thrown in (each operator is represented by a value) and has a varible assigned to it and then if that adjusts things synapses are made and it refines it to help towards making .pleas and .percentage_shots_hit as high as possible through experimentation... right now what I have is pretty simple, when it's done however I think it could be programmed into php or something and attached to a program to make it better with varibles such as performance and especially things like industrial robots... not sure it'll get quite that far however.

Offline peterb

  • Bot Destroyer
  • ***
  • Posts: 148
    • View Profile
Darwinbots replacement/clone
« Reply #23 on: April 15, 2010, 07:26:31 AM »
It was a long write; because its not possible in DB2, so i only liked to give what should be about needed for it more memory of different type.
As some people like run like 10.000 bots then the best option is to have cell differences.
So a simple cell should contain less memory, also thats new for DB in which every cell can do all, smarter would be to have cells for specific tasks, so a multibot execution is quicker.
But also since i'm thinking of multibots here, since their 'genomic' is simpler a new way should be thought of for reproduction.
A specialized repro cell might do the trick, in it some new DNA commands to have a bleuprint of a species.
Specialized cells is a different new concept, but could be nice, in terms of memory usage and in terms of evolution.
All the special command in DB2 we could think of as special cells (store nrg, eye, stpoison, shell, repro,shoot,... etc).

 

(1 head connects to a neck joint ,to a body cell, then a mirror split of 2 arms, to hands, to fingers, to keyboard, to my latop..heheheh..)


if there is enough memory for (some) bots we can later make it, and the right type like an array of var type int. ( a bit more then +32000 -32000)
To activate such code some more math commands are needed like some a sigmoid functions, some 'more precize calculations are needed.
Or evenmore complete neural math function  (sum array with weights).
I think for the moment its better to finish the clone, and i realy hope it would become readable code (with not to many magic variables); the old DB is not easy to read.
If we got clear code then it becomes possible to extend it, and maybe by more people.


These things are not worked on in DB3 as far as i know, i'm not sure how far DB3 is currently
This is maybe DB4 stuff i talk about, but if we got a good skelleton of the basic program, then a next version would be more easy to create.
And what ive seen sofar from it, seams to be better readable. (maybe not that fast?).. but promising



Oh also another answer i forgot in my earlier email, neural nets dont program the rest of the DNA to build usefull DNA to create a LOG(x) function to shoot.
It would rather become that a neural net would emulate the log function itself and give itself a shoot command. (connect the output to a shooting cell..)
(but i dont realy think that LOG(x) is required to shoot, but givven time it might improve perhaps to something like that...)
The improvement would be caused by having offspring (genetic reproduction) while advanced functioning (combining of eyes and shooting) would be a result of a small neural net.
The results might be impressive, since in current DB we create 'static' creatures, who by random noice (DNA mutations) change behavior.
In contrast nueral nets are adaptive by nature, not static
** there is a problem of learning for these bots, by i think thats much the same as zero bots problems >> Just start with enough variation and use elimination until you get some usefull Neuralnet.
Still we could use genetics as in DB, or random DNA mutations, if we can later build in a neural net then it would become much more realistic.
Most animals have brains... or at least have a concept of neurons.

Only the real small creatures dont have it, but often are so advanced allready that i'm not sure which rules aply to them ( slime can emulate the network connections between cities.. (new scientist article))


Offline Houshalter

  • Bot Destroyer
  • ***
  • Posts: 312
    • View Profile
Darwinbots replacement/clone
« Reply #24 on: April 15, 2010, 09:34:56 AM »
Quote from: ashton15
Quote from: Houshalter
I'm a bit lost reading that   Wasn't the purpose of DB to avoid using neural networks? What we need is a good "read" command so that we can use memory like an array. Theres a store, but no read.

By read do you mean * like *.eye5 reads .eye5 or .eye5 * or *505 or even 505 * it's pretty easy to read a single value, and for multiple memory locations you have things like the stack and duplicate commands... would probably help a lot if you could read various positions in the stack if that's what you mean... or do you mean having multiple stacks... I'm slightly confused by what you mean.

No, I mean having a "read" command which would take the value of the memory location pointed to on the the top of the stack and put it on top of the stack. I didn't know there was a "*" command, I thought you had to put it before the number of the variable you wanted to read.

As for your neural net, what about things that are related, but don't happen in the same cycle. For example, if you shoot, you get -2 shots back in the future, not instantly.

Offline ashton15

  • Bot Builder
  • **
  • Posts: 99
    • View Profile
Darwinbots replacement/clone
« Reply #25 on: April 15, 2010, 11:02:15 AM »
Quote
No, I mean having a "read" command which would take the value of the memory location pointed to on the the top of the stack and put it on top of the stack. I didn't know there was a "*" command, I thought you had to put it before the number of the variable you wanted to read.

Like 706 ¬ looks for all instances of 706 and put the memory locations containing it on the stack? Or like 1 *.daytime - ++ add * which reads .up in the daytime and .dn at night?

Quote
As for your neural net, what about things that are related, but don't happen in the same cycle. For example, if you shoot, you get -2 shots back in the future, not instantly.

Simple the neural net computes like computer RAM and functions with information stored on the "hard drive" which knows things like which synapses connect which to things and then it also has space just for memory that can be written to, somewhere in the unconditional tutorial thing it talks about some other way to use memory which might be helpful. Didn't entirely understand though.

Offline peterb

  • Bot Destroyer
  • ***
  • Posts: 148
    • View Profile
Darwinbots replacement/clone
« Reply #26 on: April 15, 2010, 03:36:09 PM »
Quote
As for your neural net, what about things that are related, but don't happen in the same cycle. For example, if you shoot, you get -2 shots back in the future, not instantly.
Quote
Simple the neural net computes like computer RAM and functions with information stored on the "hard drive" which knows things like which synapses connect which to things and then it also has space just for memory that can be written to, somewhere in the unconditional tutorial thing it talks about some other way to use memory which might be helpful. Didn't entirely understand though.


It doesnt matter if for a neural net something doesnt happen within the same cycle.
Put simple, if you shoot you can count up a total shots   (*.shot 1 add .shot store )
if you get food back, you can reset the shot counter.
As long as shots don't go to high a neural net doesnt trigger an action.
If shots value get to high and can choose to abandon shooting, or go faster forward.
Basicly this is way neural nets use a sigmoid function, because it switches after a "certain" treshold, in which the "certain"part adepts by a reward system.
reward would simply be gain food, or succesfully do something.

i was just thinking what if the firt memory byte (zero) was reserved for cell type and thus memory amount.
In such case less memory types would be fixed and reserved, its possible to minimize memory if you dont use eyes,
(8 types  eye, shell, nrg body, str body, movement) or if we use 2 bytes we got 16 options 4 bytes 32...
Hmm maybe i better just wait for the code before doing these suggestions.

Offline Houshalter

  • Bot Destroyer
  • ***
  • Posts: 312
    • View Profile
Darwinbots replacement/clone
« Reply #27 on: April 15, 2010, 11:15:39 PM »
I don't think your understanding me, and I'm not understanding you. Lets set aside memory locations 50 to 70 for some purpose. Say I want to access one more then the location I accessed last cycle. I would do this:
Code: [Select]
LastOneUsed 1 add readSimple, right? I ran into this problem while trying to figure out how to make the bots do complex stuff like "learn".

Also, for your neural nets, how do you find two events that are related. There could be millions of possible connections and relations, not to mention the farther in the future the reaction happens, the harder it is to identify what caused it.

Offline ashton15

  • Bot Builder
  • **
  • Posts: 99
    • View Profile
Darwinbots replacement/clone
« Reply #28 on: April 16, 2010, 05:15:06 AM »
def last_read 971

start
70 .last_read store
.delgene inc
stop

start
'condition
*.last_read ++ *
'whatever you want to use the number for
.last_read inc
*.last_read 91 = and
70 .last_read store
stop


Like that? That's the simplest way I can think of... really hope that's what you mean this time.

Quote
Also, for your neural nets, how do you find two events that are related. There could be millions of possible connections and relations, not to mention the farther in the future the reaction happens, the harder it is to identify what caused it.

number of varibles to the power of two, 250ish sysvars and lets say 100 custom varibles which makes 122,500 but not every varible depends on every other varible for instance shot travel distance depends only on body and shootval so to make up for this I divided that by 5.5 (could be any number) to get 22,000, thus using the 25,000 memory locations I proposed ealier, 22,000 are part of the neural net, 350 are varibles and leaves 2,650 for genreal memory and if that memory is spread over how ever many cells are in the brain it should be sufficient to allow for human intelignence, right?
« Last Edit: April 16, 2010, 05:27:41 AM by ashton15 »

Offline Houshalter

  • Bot Destroyer
  • ***
  • Posts: 312
    • View Profile
Darwinbots replacement/clone
« Reply #29 on: April 16, 2010, 10:00:19 AM »
Quote from: ashton15
def last_read 971

start
70 .last_read store
.delgene inc
stop

start
'condition
*.last_read ++ *
'whatever you want to use the number for
.last_read inc
*.last_read 91 = and
70 .last_read store
stop


Like that? That's the simplest way I can think of... really hope that's what you mean this time.
Maybe, I'm not sure what your trying to do with it though. Heres a better example: I have a shepard bot. It grades the fitness of a bot it sees in front of it and stores that value in a memory location. I have ten memory locations and the number of the location I last stored in and I want to rotate through them. Its easy to store them using "last_value 1 add store" but its hard to read them. For example, what if I want to find what the last bot's fitness was? Ideally I would do this: "last_value read". Now the value of the last bot's fitness is on top of the stack and I can use it to compare it to the bot I see now to judge what his fitness is.

And do you really think you can simulate human intellegince in darwinbots? That would be weird.