Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - peterb

Pages: [1] 2
1
Darwinbots3 / alive ?
« on: July 03, 2010, 06:12:45 AM »
alive software, stands for life simulating software.
not wanting to put pressure on anyone here but i wonder if this project is still a live.
or that it lost its sparkle of life, wellwe know species dont live forever.

i think i can conclude there are many ideas of how it could / should work, but ideas are easier to create then programs.
as a last idea i propose a modular design.


Above all, modules should be first explained in clear text of what they do, so even beginner programmers can use them, how to call their functions, and put explaining of their functions inside the code in readable english. (explain every function)

Good explaining might me be equal or even more important then the code itself, a requirement is other people even wit low programming skills should be able to use the code, or improve it by introducing new ideas to it. I would sugest using phyton for this since it has an easy modular format, and it is free so anyone can develop with it.

2
Bugs and fixes / Running on multi core processors. (how to)
« on: May 11, 2010, 05:39:56 AM »
I think this subject has now passed many times on the forum.
So maybe i should explain how to run DB on multiple cores, that is you can assign each program a specific CPU of your multicore system.

Press CTRL + ALT + Dell to open taskmanager
Go to processes tab; there you see a list of all processes that are currently active
Then right click darwinbot2.44.exe     (or whatever version your using)
right click it and then there is an affinity option where you can choose on wich core you run the program  
Default all processes run on all cores.  (but now you know on how to specify it)
It makes only sense to change this for processes that usage a lot of CPU (so you dont need to change all processes).

A next thing you can do is to set the priority of the process.
Basically threading is a technique so that multiple processes run (almost) parallel, side by side; thats why you can have multiple programs (windows) inside windows NT4 2000 XP vista 7 etc...
In the earlier time when people used D0S 5.x this wasnt possible, only one process could run, one program was active.
In a multithreaded environment all programs stay in a row and the CPU's divide their attention to all them switching CPU cycles between them all.
By changing affinity you change how much attention to a process is given by the CPU full attention is realtime
Realtime might result in an unstable PC and even become nonresponsive, as the prog gets all attention) ==> better is High or above normal, or just keep it to its default which is fine too.(but slightly slower)


A next thing you might consider is to use teleporters between your sims; get a free FTP server prog run it localy and your done.
(supported number of cores can also depend on your windows version)



well i thought lets explain it for people who didnt know this; your not all deep into the windows operating system.

3
Some deep background on collision detection math, and how to do it fast; well its from nvidea they benefit from explaining it.


http://http.developer.nvidia.com/GPUGems3/gpugems3_ch32.html

Although couldnt see the link in the article but the above url reads GPU... and yes its done in CUDA so this routine offloads the CPU !!!!

4
Suggestions / new Code center sub
« on: April 29, 2010, 03:57:02 PM »
i would sugest a new top level sub in the code center.
An area where we could post routines of code, and improve each others routines maybe.
Could be in any language VB6 VB.net python c++ c C# etc

I think throughout the history of darwinbots various people have tried to improve code.
And some had suggestions, while other would like to begin.

But as a whole its like a monster project...

 >> reading DNA,
 >>improving graphics with openGL or DirectX,
 >>colission detection,
 >>physics of bouncing,
 >>FTP    
 >>saving game
 >>or general ideas.. how should swimming work etc.. with code samples


PS
i begin to like Python (i'm using v2.6 with a free editor, python scripter)
I also got visual studio 2008 but its not free, so not everyone can code in that.
Python is free, and simple to read has a lot of free and really advanced libraries acka modules (which you can google to include)
Modules for :  music, graphics, openGL, directX, math, neuron math, games (sprites), video,ftp.. wel lots lots and lots.. and free!
there even is a module which allows inline c++ , so the main prog can be simple to read while complex parts can be improved wit c++
And if you think that's not fast enough, there is even inline assembler support nothing beats that..
(well, a compiler usually is better then you to convert any language to the final assembler)

5
Off Topic / Programming Fast circle code for OpenGL
« on: April 22, 2010, 07:33:50 PM »
FAST Circle draw routine

Below a fast routine to draw a complete circle in OpenGL
Since other programmers here can benefit from it, i drop the code here
.
My demo code is mainly a routine which does draw a lot of circles about 166 from small to large.
It does draw a lot of circles which seams to 'scrol by' but in fact they're all redrawn so it shows the speed of this routine..
Usually drawing large circles is a slow operation....
Its fast because i minimize complex math like sin and cos (which in this language is called sind and cosd).
It should require little conversion to rewrite this to C++ as i used Basic4GL which nativly supports openGL v1.0

main routine splits the drawing and start drawing from top bottem and both sides.
lines will be drawn till 45 degrees since i start from 4 sides, at 45 degrees the lines connect to a circle.
Delta defines how often splits are made (and so a one time recalculate with cos and sin is needed).

the code can even be more optimized for real small circles (using a few sprites)


I found an equivalent for line(x1,y2,x2,y2) in the OpenGL command   glBegin(GL_lines) (see pic below code)


This code runs in Basic4GL (handy to test openGL routines), it not a full blown language like vb6, vb.net, or c++
But typing is easy and since it uses openGL its amazing Fast.. (but not complete enough to make DB clone in it, lacks mod function and others).

[div class=\'codetop\']CODE[div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']
const Xsize = 1000, ysize = 600
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
glOrtho (0, Xsize,Ysize, 0,0,1)
glMatrixmode(GL_MODELVIEW)
     
'turn of depth
 glDisable(GL_DEPTH_TEST)        
'clear screen
 glClear(GL_COLOR_BUFFER_BIT)          
 
          'http://basic4gl.wikispaces.com/2D+Drawing+in+OpenGL  
dim radius as integer
dim xpos,ypos  
dim w1,h1,w2,h2,corner,delta,i
   
for i =1 to 800  
xpos = -400+i
ypos = -400 +i    
     
       
 For radius = 0 to 500 step 3
     
        glClear(GL_COLOR_BUFFER_BIT)  
        glBegin(GL_LINES)  
        corner = 0
        w1 =  0
        h1 = radius
       

    if radius < 300 then delta = 6     endif
    if radius < 280 then delta = 10    endif
    if radius < 100 then delta = 15    endif
    if radius < 60  then delta = 22    endif
    if radius < 15  then delta = 45    endif
      while  corner <46
        corner = corner + delta
                                         
        w2 = radius * sind(corner)
        h2 = radius * cosd(corner)
         glVertex2f(xpos+w1, ypos+h1): glVertex2f(xpos+w2, ypos+h2)
         glVertex2f(xpos-w1, ypos+h1): glVertex2f(xpos-w2, ypos+h2)
         glVertex2f(xpos+w1, ypos-h1): glVertex2f(xpos+w2, ypos-h2)
         glVertex2f(xpos-w1, ypos-h1): glVertex2f(xpos-w2, ypos-h2)
         glVertex2f(xpos+h1, ypos+w1): glVertex2f(xpos+h2, ypos+w2)
         glVertex2f(xpos-h1, ypos+w1): glVertex2f(xpos-h2, ypos+w2)
         glVertex2f(xpos+h1, ypos-w1): glVertex2f(xpos+h2, ypos-w2)
         glVertex2f(xpos-h1, ypos-w1): glVertex2f(xpos-h2, ypos-w2)
   
          w1 = w2
          h1 = h2
          wend
   
       next
        glend()


line types

6
Mutations / Mutation: from evolve-2(x) series
« on: April 09, 2010, 07:24:06 PM »
I was a bit amazed by this bot, the main movement gene was mutated to move sideways ???.
We almost never design bots to move like crabs, but apparently its not so bad.
the eyes acted more like ehmm a fishnet, the robot didn't move to fast, but still was pretty reproductive.
Only when it sees something it moves forward to eat to eat it, otherwise it walks sidewards.
I never would think it would work, but it was pretty good actually.
It had lots of offspring, and .... it seamed to catch better !!,  but why ??

Hmm maybe the side walk of a crabs in nature, does have a benefit ??

What i can think of is that the catching, although more difficult,
has less chance of chasing long, resulting, in giving up, 'out of reach targets' earlier,
and getting the ones nearby more easily...???
well its a gues.



Code: [Select]
''''''''''''''''''''''''  Gene:  1 Begins at position  1  '''''''''''''''''''''''
 cond
 *.robage 30 >
 *.eye5 0 >
 *68 0 =
 start
 *67 sgn 1 add sgn 60 store
 -32 *.eye5 div .shootval store
 -1 .shoot store
 *.refxpos *.refypos angle .setaim store
 -1 *60 mult .shoot store
 0 .fixpos store
 *.refvelup 20 add *60 mult .up store
 *.refveldx 7 div *60 mult .dx store
 *67 1 add 67 store
 *.pain *.pleas sub sgn 1 add sgn 1 sub abs 3 mult *64 add 64 store
 *.pain sgn 1 sub abs 66 store
 *0 sgn 1 sub abs *66 add sgn *64 add 64 store
 *64 150 mod sgn 1 sub -628 mult .aimright store
 *64 150 mod sgn 1 sub -1 mult .fixpos store
 *.slime 50 sub sgn 1 sub sgn -7 mult 60 store
 *.refmulti *60 mult .mkslime store
 *.eye5 40 sub sgn 1 sub sgn -1 mult *.refvelup 61 store
 *.up 60 store
 60 *0 add * .up store
 stop
''''''''''''''''''''''''  Gene:  1 Ends at position  151  '''''''''''''''''''''''

''''''''''''''''''''''''  Gene:  2 Begins at position  152  '''''''''''''''''''''''
 cond
 *.eye5 0 =
 *.robage 30 >
 *68 0 =
 start
 *.eye9 *.eye1 sub sgn 54 store
 *54 130 mult .aimright store
 *54 abs -1 add abs 5 mult .up store
 *54 abs -1 add *.mass mult .dn store
 *.robage -2 div .dx store
 10 .up store
 *.eye6 *.eye4 sub sgn 63 store
 *63 35 mult .aimright store
 *.eye6 *.eye4 add sgn abs .fixpos store
 *.pain 1 sub abs .pain store
 *54 abs 65 store
 *63 add *65 abs sgn 65 store
 *65 *64 mult 64 store
 *67 1 add 67 store
 stop
''''''''''''''''''''''''  Gene:  2 Ends at position  244  '''''''''''''''''''''''

''''''''''''''''''''''''  Gene:  3 Begins at position  245  '''''''''''''''''''''''
 cond
 *.nrg 16000 mod 0 =
 *.mass 2 >
 start
 -4 .shoot store
 *.waste .shootval store
 20 .strbody store
 20 .mkshell store
 -40 67 store
 30 68 store
 stop
''''''''''''''''''''''''  Gene:  3 Ends at position  273  '''''''''''''''''''''''

''''''''''''''''''''''''  Gene:  4 Begins at position  274  '''''''''''''''''''''''
 cond
 *.robage 30 <
 start
 *.tiepres .deltie store
 500 .dx store
 *.robage 5 sub sgn 1 add sgn 500 mult .dn store
 *.robage 20 sub 0 floor 9 mult .aimright store
 stop
''''''''''''''''''''''''  Gene:  4 Ends at position  305  '''''''''''''''''''''''

''''''''''''''''''''''''  Gene:  5 Begins at position  306  '''''''''''''''''''''''
 cond
 *68 0 >
 start
 41 .aimright store
 4 .repro store
 *68 1 sub 68 store
 stop
''''''''''''''''''''''''  Gene:  5 Ends at position  322  '''''''''''''''''''''''

''''''''''''''''''''''''  Gene:  6 Begins at position  323  '''''''''''''''''''''''
 cond
 *.body *.refbody <
 *69 20 <
 *.robage 5 mod 0 =
 start
 300 .shoot store
 50 .shootval store
 *69 1 add 69 store
 stop
''''''''''''''''''''''''  Gene:  6 Ends at position  347  '''''''''''''''''''''''

7
DNA - General / working with relative pointers inside DNA !
« on: April 09, 2010, 05:29:01 PM »
Hey

In program languages you see often something like ^P+
  • , the pointer to variable p and x offset of that memory adress (basically arrays work like that)

after reading the wiki i came to the conclusion that it should work also inside darwin bots genes

Maybe its something for the wiki page

Here is my sample code which explains it:



def temp0 60
def temp1 61
cond
*.eye5 0 >
start

'Have some code to move
'So that *.up has some valeu, put it in .temp0

*.up .temp0 store
'Now if it is a multibot, get that remote bots speed store it in temp1
*.refvelup .temp1 store
'Depending on multibot or not add 1 or zero to the addres of mem1  (not the valeu stored there but the addres of where it is)
'Then the single * tells the engine to get the previous number as an adres to get value from, and put that in store.

.temp0 *.refmultibot add * .up store
'so here .temp0 acts as a root pointer,  refmultibot acts as a relative position and * gets from there the value
stop


8
DNA - General / Anti bigberta gene..
« on: April 09, 2010, 02:33:40 PM »
Something fun against large enemy cells..
Since a lot of bots get stronger when they are big, how could a small bot win from such larger one ?
Here is a surprising way, how about forcing the stronger one to do a repro 50% size  
So here i'm presenting a viagra shooting gene  

I used this code.
With a sneaky parameter which is reset to zero if the bot doesnt see anything.
Now it forces biger cells to repro smaller, every 5 cycles as long as it is insight.  
So other shots can be normal shots, and i use it as the last gene.


cond
*.body *.refbody <
*.sneaky 20 <
*.robage 5 mod 0 =
start
.repro .shoot store
50 .shootval store
*.sneaky 1 add .sneaky store
stop



I've included the gene in Evolve-2C  who got a nice repro system itself (shoots it's offspring around in a circle).
Well that is unless it is attacked by its own kind, this cell is cannibal cell, and so above gene would fire on its own kind too.
But being small is not such a big problem now as it has this gene above...

9
Untagged bots / Evolve II
« on: April 07, 2010, 11:57:36 AM »
This bot is opportunistic, it tries to shoot.
But each missed shot counts as a bad shot.
To much bad shots or pain, result in a fixed pos and later later even a turn away.
Based on that the following behaviors could be seen :

  • It will not endlessly hunt to fast bots, it gives up after a while (give up
  • It will not circulate around a veggy forever (fixpos re-orientate and attack
  • Hard to get targets will not be hunt forever (give up

its not the greatest danger this bot, but its i think an intresting behaviour bot.
Also the reproduction isnt that complex, i was mainly designing a bot that wouldnt circle around forever and that had some kind of gain and pain system, on which it acted.


10
Bot Tavern / A Cosine function, with no tablebase usage.
« on: April 04, 2010, 09:29:34 PM »
cosine (from +100 to -100) , based on the 1256 darwinbots  x degrees

notice i kept the value of e inside here since there might be different ways to optimize this math into to darwinbots.
e is about 2.71828182845904523536  (source wikipedia)

the function cos(x)*100  as  f(x) =  

      100.336
      + 1.55527e-015*x*x*x*x*x*x
      + 6.72543e-009*x*x*x*x
      - 1.48672e-006*x*x*x
      - 5.86017e-012*x*x*x*x*x
      - 0.000986079*x*x
      - 0.0193941*x
__________________________(sum)


PS
I don't deserve big credits for it, I'm just playing with my new math toy and giving it some tests.
Still it might be useful for those who want to play with sin and cos   sin (x) = cos (x-324)
So we can create Spiro-graphic effects  
Notice i let result from -100 to 100 for integer rounding reasons    true cos should have a final 100 div after it.
I'm not sure how precise it will be these function inside the integer universe of darwin bots.
My mechanical turk , is going to keep number crunching on the data set so maybe i have a better function tomorrow.
But i doubt it as this is pretty near to the real thing..
Note this function might require mod function for its input 1256 mod

hmm and it might be that *x*x*x*x*x*x  results in overflow...

11
DNA - General / shootval and distance for -1 shots
« on: April 02, 2010, 06:06:19 AM »
I'm trying to figure out a formula for shootval so that the bullets are shot with the right distance.

But on the wiki sysvars i dont read how it behaves.
Here on the forums i read some words about   log2(distance)  ??
However log2 is not an operator in DarwinBots , what might come close to it is bit operation >>  ???
So far i failed to write a good formula and searched the forums and wiki, and the beastairy.

Has someone already solved it. ??
How to perfectly shoot at something with the right distance.

Also i think .mass impacts a shot distance ??,  but  'm not sure but bot size and shotlength dont seam to compare

I can figure out how to get the distance and angle with :
*.refxpos *.refypos dist .edist store
*.refxpos *.refypos angle .setaim store
-1 .shoot store


But now how to shoot exactly to it ? (or with a margin : *.edist 10 add .edist store)

12
DNA - General / food finding and eating genes
« on: March 30, 2010, 05:13:58 PM »
I'm trying to figure out good food eating and aiming genes

I've made below, besides that i wonder if the code is good (can i use multiple times .up ?)

What i would look is that it would move to 3/4  or maybe 1/2 of the distance between its target.
So no matter the speed or its own body mass (it requires some adjustments).
The shooting is allready quite good, and it less often does circle around algeas
And even while pretty big it speeds up a lot to for example to meetup with Efilans or others  (but will soon be outnumbred no repro so far)

The only problem is it can stay behind a enemy without ever coming closer if they move  (algea work fine)

here is the code so far.


Code: [Select]

'Polinator
'requires 2 types

def reproval 50    '10...100
def bigsmall 51    '10...100
def direction 52
def etarget 53
def eyetemp 54
def shootnow 55
def shootdist 56

'=================================================================
'GENE FOR FINDING FOOD
cond
*.eye5 0 =
start

'eye9 or eye1 are (each eye = 35 units, *4 = 130
'
' if we see something get fixed and turn into its direction.
' next the GENE FOR EATING  will run for it
'

*.eye9 *.eye1 sub sgn .eyetemp store
*.eyetemp 130 mult .aimdx store

0 .fixpos store
'  nothing insight +10 up
*.eyetemp abs -1 add abs 5 mult .up store
*.eyetemp abs -1 add *.mass mult .dn store
*.shootdist *.mass mult *.refvalscalar add .up store

stop


'====================================================================
'GENE FOR EATING   'using advanced shooting mechanism
cond
 *.eye5 0 >
' *.in1 *.reproval !%=
' *.in2 *.bigsmall !%=
'*.refeye *.myeye !=
start

*.refxpos *.refypos dist .shootdist store

' .shootnow   this mimics *.eye5 > 40  and gets a valeu of (0|1)
*.eye5 40 sub sgn 1 add sgn .shootnow store

*.refxpos *.refypos angle .etarget  store
1256 *.aim sub *.etarget add .etarget store
1256 *.etarget sub .etarget store
*.etarget .aimshoot store

*.etarget .aimdx store


*.shootnow .fixpos store
*.shootnow -1 mult .shoot store
'0 .fixpos store
*.shootnow 1 sub abs .shootdist mult 2 div 1 rnd add .up store

stop

end

13
Bot Tavern / developing self tuning bot based on evolution / dna
« on: March 29, 2010, 10:05:27 AM »
I am not sure if this already has been done, i'm working on the following :

A simulation that competes for the best bot parameters.
For example a big impact of A and B in the following :

Cond
*.nrg > A
start
B .repro Store
stop


In my sim each plant has a random out1 for A and out2 for B
Robots startup and take the first valeus from the plant they see first (kinda random).
Also the robot will then put A for out1 and B for Out2 as a result their ofspring will also use those.
Since robots also determine A and B for checking if they are relatives, you get different species inside a single bot gene, with different behavior.
Both check with !=% (10% range) if other bot's are family on both A and B valeus and if not eat them.
Ciblings might change A and B values maybe later with 5%


.. i notice however that to much energy gets into the sim
so i need to make moves of bots cost more energy and also i think i should somehow limit plants not to become too big.
as with to much energy the sims then to get crowded by tiny bots.


What i wonder have more bots been made to try something like this ?.
For example to balance and find optimum eye distances or something else ?


included as zip file the work so far, note some parts have been marked out, as it seams it has some kind of move aiming problem  (Gene 7) of the 8 genes.
I often see it circle around a target and doing nothing, sometimes 9 a bit to often it doesnt attack, still trying to figure out why not, so there i placed some marks  to disable "not killing family"
The included vegies are part of this kind of sim, its default sim and the vegies dont need to be fixed.

14
Bot Challenges / simulation fish population evolution
« on: December 03, 2008, 07:32:39 PM »
 This might be an intresting thought

recently in the newscientist there was this article http://www.newscientist.com/article/dn2505  
about fish populations, that fish adapt and become smaller fish if we catch the big ones.
it would be better to leave out the big ones.

From a darwinbots view, this makes sense, we all know bigberta bots can reproduce lots of ciblings.
Now the article mentioned they used some simple kind of software (it didnt mention what kind).
Dough it might be intresting to simulate this, maybe find some proofs or find other new things about fish population control.

To setup something like it, I think a sim would look something like this..
There are fisherman ships, they multiply slowly and depending on the fish population.
If they catch to little they have to dye (by shooting at no target, loosing energy).. in real live it would be the ship lost its work and was removed from sea.
But maybe they dye simply and such extra dye trick isnt needed.

Then the fish, they should have an age system
Below a certain age not allowed to reproduce.
Here is species specification, because its DNA must some how evolve to find an optimal birth rate.
Maybe sex repro ?, or a in out system, to talk about repro its age.
Fish feed on a few vegies only, it would be nice if fish would swarm in groups from about the same age a bit like in real life.
I'm not sure if fish prefer to do repro with someone from the same age, maybe use a %= there to match. or by math get it to 60% or 70% or so... maybe that number itself might change too.
Also bigger fish lead to bigger offspring
while smaller fish lead to smaller offspring.
To keep it simple at first the number of childs shouldnt be depend on fish size.
(so use a counter for example to create 10 ciblings, and try to keep their seize equal)


fishing ships cannt feed on veggies, (for example using in out communication system, to detect)
some where in the ship script you should be able to set, which fish age range they catch

To make it slightly more realistic perhaps work with seizons for reproduction, I'm not sure if fish keep track of it but I do think so.
I think this can be done using the mem range 971 or so they go to ciblings, and so then you can use a mod counter on it
so while day mod 365 <50 or so

oh and there might be also a natural fish enemy, using slightly the same rules, a shark.
It does feat only on fish, not on ships not on algey, it does this on any size fish
maybe the ships should also be allowed to catch them/ but first try without it.
Sharks are a bit bigger, and they shouldnt be able to kill all fish since that would mean the end of their population too.
it could be achieved by for example test the number of total species compared to its own; keep a ratio of 10 : 2 or so.
A fish who gets to close to a shark should stop moving, and feeding (sharks always win from fish)
Like ships always win from fish.







15
Untagged bots / W6 a verry strong multibot
« on: December 02, 2008, 04:48:52 PM »
'
Try to defeat me..
  ________  ______  ______  ______  

' confidential
'
'                             Super multibot codename w6.txt
'
' w6 a deadly experiment it is still a code name
' A genome which uses some advanced strategies
' It is deadly, so wear protected clothing all times.
'
' Still the bot lacks complex head construction or good eyes.
' Doesnt move optimal, but it shoots like a goalkeeper
' Independant of its travel direction it aims at enemies who are in range
' It can even attack multiple enemies at once, as if it feels them nearby.
' In fact it might not even turn his head (heading) to kill you..
'
' It does use poison, sometimes venom, but no tie feeding on others
' Also it doesnt use viruses, so its a fairly fair.
' there will become a w7 also later... even more deadly.
'
' It has a special form of birth control to deal with various
' enemies, for example it has a high and slow birth rate.
' usualy it breaths slowly growing big while other multiply
' While they multiply it invests in becoming powerfull
' But that is depending on its environments population ratio.
'
' It can form bigberta supperkillers, who will be not fast
' Dough they're good in reproducing. And seeding the environment
' Overall its more a tactical bot, as it uses various tactics
'
' It has a huge genome, for its tactics
' As I wanted its population to be more adaptive.
' Now its verry dependant on its environment.
' in some situations you'll see big berta's multibots
' Other times you'll rarely see them team together.
' Rarely it fires a tie to a algea an error, its not a batery bot (bad aiming).
' It depends much on population size, how it will look like
' A big bot connected killer swarm
' or hundreds of small ones who connect less often.
' And only a few might re-populate and still win the battle.
'
'
' I wanted to defeat snakebot (thats the best looking bot I think)
' Then I tried it with other bots
' And I noticed it does defeat many other multi bots (or most ??)
'
'  
' So pleace note your multibot if it outperforms w6.
' (also include your enviroment settings ...  field size, number of algeys friction method etc)
'
' by Peterb


Pages: [1] 2