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.


Messages - peterb

Pages: 1 [2] 3 4 ... 10
16
Off Topic / Programming Fast circle code for OpenGL
« on: April 29, 2010, 06:49:00 AM »
Quote from: Numsgil
Quote from: peterb
Quote
You would be fine to use sin and cos, since they're only called once when you build the display list.  After that the vertex positions end up being stored on the graphics card.  So it beats out trying to re-send the data across the bus for every circle for every frame.

ehm .. ??
How does that work my routine uses a minimum of sin cos commands but their values, you can store them in the graphic card ???

Yes.  More to the point, graphics cards can only draw things which are stored in a hardware buffer anyway.  So your openGL commands get converted in to that anyway.

I'm not sure if i'm following this you mean that a 'drawn' object is stored in the graphics card
And so you can then adres a whole object like move all the lines by 1 vector ??  (moving a poly line)
(so no redraw of the complete circle ?), only have one command like move object(XXX) by vector(x,y,z)   //z=0
In my sample i just redraw each frame.
If move by vector is possible that would be way faster..




17
Off Topic / Programming Fast circle code for OpenGL
« on: April 28, 2010, 02:19:00 PM »
Quote
You would be fine to use sin and cos, since they're only called once when you build the display list.  After that the vertex positions end up being stored on the graphics card.  So it beats out trying to re-send the data across the bus for every circle for every frame.

ehm .. ??
How does that work my routine uses a minimum of sin cos commands but their values, you can store them in the graphic card ???
the routine is a buildup of lines from 8 start points my circle (from top left right and bottem, in 2 directions makes 8)

18
Off Topic / Robots learning environment
« on: April 27, 2010, 06:08:45 AM »
Quote from: Numsgil
Interesting.  I'd be interested in knowing how long it takes an actual physical robot to figure out locomotion.  And yeah, as Househalter said, how is it picking self models?

actualy quite fast see the movie http://ccsl.mae.cornell.edu/research/selfm...ent_428x240.wmv

19
Bot Challenges / Evolved Neural Network
« on: April 26, 2010, 06:07:35 PM »
Quote from: Numsgil
Quote from: ashton15
Quote
.... thinking futher.. maybe all these DNA codemay exist then in each cell (just as our DNA) but only have the right ones active..
Still then we ned another way of repro (to build at once the same complex child with a repro)
Isn't this bieng worked on for DB3?

I'm thinking that after repro it ends up copying all the memory as well (or allowing a bot to specifically do this/not do this).  So if you have a neural net with dynamic weights and you repro all those weights get preserved.  But I'm not 100% about it either way.


Well having read somethings about it    

There are some interesting things about NN, for example if a single neuron dies... its not a problem (if the NN isnt to small), they as a group adapt.
On the other hand (DB shape = function) to suround such cells with some common cell with a lot of .shell (otherways creatures attacking brains get nasty killers.. ohwell its ok too..).
In reality if you drink some alcholic you wont die because some neurons got killed, after some drink you behave funny, but later you repair, your 'mind' isnt erased.
There are some neural nets (also in todays post at another topic here : http://ccsl.mae.cornell.edu/emergent_self_models  
That realy learn from no awernes to walking (i've seen a documentary about that bot, its kinda rocket science)

It means if the net is real good it might tweak and tune itself (starting from some randomization values)
I think for us here starters in this field / copying values within some margins of the parents value would be more likely.


You know also interesting is that most ófficial books (not all)  talk about 3 or more layered NN
But it is not realy required.... the brain isnt a layered structure in 3 or more layers.. its more complex.
I dont want to create such a complexity as the brain,  however it means if the right logic in a single neuron bot, then it isnt limited to a layer structure
In essence shape as MB shapes might become more functional, ..or even evolve by well some darwin rules, we allready now from DB.

Also the right code doesnt mean the sim would get slow, its only some tie communication we allready can do, but have not done in this perspective i think.
It woulod only mean a bit more tie communication.. oh well computers are known to be able to do NN beter then me using a calculator...


But this 'new' multibots need a way of beeing created, an external editor (and once created some kind of  DNA string or bleurprint ( ??? ideas on that ??, save ties positions ?? )) for .repro

(because it so different i have been thinking of cell differentiation earlier.. a rebro bot, not much command processing only smart at repro, while others are only good at other specific functions)

also interesting just notice the general things a NN can do from this article http://www.sciencedaily.com/releases/2010/...00425151146.htm (pretty hot stuff)


I'm not thinking DB would be the best NN simulator, but i think having it all combined a NN a genetic part, and shape (of a MB) to be a factor of function.. is pretty close to exciting biology emulation..



i think you get the idea


( oh and check this out, someone is doing something verry similair to DB in java with neural net "cells" http://tim.hibal.org/blog/  (asbout halfway his blog..




Getting some NN inside DB is my reason to code again, but maybe my previous aprouch to learn opengl (intresting...) etc, wanst the right direction..

20
Bot Challenges / Evolved Neural Network
« on: April 26, 2010, 11:55:10 AM »
Quote from: Numsgil
Quote from: Moonfisher
I don't think the way DB code works and a NN are all that different when it comes down to it.

Came to the same conclusion when I was redoing DNA for DB3.  I was toying around with the idea of a neural net with programmable weights, but realized it was becoming regular old DNA anyway.

... We try to make neural nets inside a single bot, thats the problem i think.
Another aprouch is to Design (outside of DB ?) a multibot in which each bot equals a single neuron.
Still it is complex (because of all connected ties (and getting them connect to the right other neuron).
But if you can do that .... maybe its possible.

I think this rather requires some kind of external multibot editor.
who can put it in a safe game format.
And in which each bot we can put specific DNA.. well let call it protains functions )

As to safe such multibot (like .repro) we would need a new repro command to put such advanced bleuprint trough..

.... thinking futher.. maybe all these DNA codemay exist then in each cell (just as our DNA) but only have the right ones active..
Still then we ned another way of repro (to build at once the same complex child with a repro)

..
hmmm.. then if you got it... how to train it ?  (is food enough to train it?)


21
Off Topic / Programming Fast circle code for OpenGL
« on: April 26, 2010, 07:44:39 AM »
Quote from: Numsgil
Quote from: peterb
Quote from: Numsgil
glu is just a wrapper around OpenGL, so it shouldn't be faster than well formatted OpenGL.

So then this code this OK then

Well you could use a display list.  Essentially it'd be like creating a precomputed stamp of a circle.  Then you could feel free to use sin and cos all you want since it would only get called once, and then cached afterwards.


hmm i like to minimize cos and sin calls since these functions are complex and thus slow i think.
I'm not sure if darwin bots works with a bots direction, or rather with a deltaX & deltaY ( i think sin cos are only required when a collision occurs
Circle collisions might however be more complex, since a small circle can bump into a larger one... hmm collision checks must be a whole big topic..

22
Off Topic / Programming Fast circle code for OpenGL
« on: April 24, 2010, 06:31:38 PM »
Quote from: Numsgil
glu is just a wrapper around OpenGL, so it shouldn't be faster than well formatted OpenGL.

So then this code this OK then


Hmm the only improvement left might be to replace the sind and cond with an array with a depth of 5 (dont require more values since i use only a few angles
well maybe thats not even required such a large circles are not practical in DB

23
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

24
Newbie / Darwinbots replacement/clone
« on: April 21, 2010, 04:36:05 AM »
Quote from: Numsgil
Quote from: peterb
HMM

GL_Line_Loop

thinking of something fast to create n sides (its slow to do all with cos and sin) ,
basicly a quarter of a circle, or even maybe 1/8 is enough to get all X,Y positions ... hmm thinking fast routines no (zero) divisions and re-using values, and arrays.

Yeah, you'll want to use a line loop probably.  You can bake the vertices into a display list.  That's being pretty old-school but it's fairly easy to set up vs. the speed you'd get.

Quote from: peterb
Numsqil what do you think of this :

idea for openGL

The more precize the circles are, the less circles you have to draw since the viewscreen is zoomed in..
So .. ideas get more complex, but also you dont have to draw anything outside the current viewscreen (speeding things up).
I'm not sure if the program needs to know what is inside the viewscreen (vb.net could be aware of that).
So a circle routine has to be aware of the zoom scale.

That's how I'd do it using the fixed function pipeline in OpenGL (as opposed to shaders) for highest quality graphics.  But it's a bit of an effort to code up.

Quote
for some simple math testing for this i'd like to have a... simple language to draw.. duh.

hmmm i'm beginning to wonder if c++ might be more easy for this all together, as might tackle to many problems at once.

Did you get Tao working?  I found it very easy to use.  The only hard part was adding the Tao graphics control to a winform (hard as in tricky to navigate through all the menues and everything).   You can probably steal one of the NeHe tutorials as a starting point.  I think the C# source code for them uses Tao.


I first need to get a bit known with openGL so i first will play with that other basic variant, since it understands native opengl commands
Later i will use TAO,... yep i allready been reading about that part seamed complex to me too, how to get it into a form/picturebox ..first openGL it is.


OH BTW just woke up with another speed improvement idea (not sure if it is allready used)
We only need to calculate with sin / cos after a colission, we dont have to do it each time.
.. and apparently opengl does understand movement to (matrix movements, and matrix turns)....
 

25
Off Topic / .net crashing, no error help, any ideas?
« on: April 20, 2010, 07:07:16 PM »
Quote from: Botsareus
So it is like a modified ‘On error resume next’. What a pain!

Quote
System.OutOfMemoryException
System.NullReferenceException
Syste.InvalidCastException
Syste.ArrayTypeMismatchException
System.IndexOutOfRangeException
System.ArithmeticException
System.DevideByZeroException
System.OverFlowException

The main problem I see here is: I have no idea what is the exception for RGB getting a number more then 255? What if the program is just crashing on me and I have no idea what specific exception is happening, is there any way for .net to tell me what specific exception I am dealing with?

mybe the fasted way to solve your max 255 value is to perform
X and 255   'fastest

i dont know why you get over 255, but try to limit usuage of devisions  (devided by zero)
Other options are to set breakpoints or to print all the variables  on screen or in the debug field.
But basicly i think thats the art of programming to for see such events, and use clean logic routines as much as possible.

You can also turn on strong typing (so you have to declare everything) and so get less errors from mixing up variants integers doubles etc


26
Newbie / Darwinbots replacement/clone
« on: April 20, 2010, 06:30:44 PM »
Quote from: Houshalter
Quote from: peterb
I've seen the GDI sample, they remind me of the pen up and pen down commands of logo, which i never was a fan of..
You mean turtle graphics? Whats wrong with them?


I had to learn logo at school while i had at home an MSX in those days (which was graphically way more advanced).
It might be something else too, i never like penwidth or patern fills, i like 32bit collors when they where available.

ANYWAY i found something COOL

Its called BASIC4GL   (google for their wiki space and download it from there, the main site seams to be offline).
A basic compiler with openGL language support, the basic isnt as advanced as vb6 or vb.net, but it does do fast openGL...
So now i can experimenting drawing in OpenGL before i write somekind .net program to get familiar with openGL.

27
Newbie / Darwinbots replacement/clone
« on: April 20, 2010, 04:39:27 PM »
Numsqil what do you think of this :

idea for openGL

The more precize the circles are, the less circles you have to draw since the viewscreen is zoomed in..
So .. ideas get more complex, but also you dont have to draw anything outside the current viewscreen (speeding things up).
I'm not sure if the program needs to know what is inside the viewscreen (vb.net could be aware of that).
So a circle routine has to be aware of the zoom scale.


 for some simple math testing for this i'd like to have a... simple language to draw.. duh.

hmmm i'm beginning to wonder if c++ might be more easy for this all together, as might tackle to many problems at once.

28
Newbie / Darwinbots replacement/clone
« on: April 20, 2010, 02:19:43 PM »
Quote from: Numsgil
Quote from: peterb
I've seen the GDI sample, they remind me of the pen up and pen down commands of logo, which i never was a fan of..
I've been thinking too to use sprites for circles, that way no calculations..hmm
but they need to rotate as well, and scale not sure if that is something a graphic card does do fast.
Would it be better to scale, or to have multiple sprites of different sizes ?

Yes, they use transformation matrices to handle scale, rotation, and translation of triangles.  Once the triangles are placed in screen space, they get their texture sampled and applied.

Textures/sprites have the advantage that they require fewer pixels.  But they'll get pixelated if you zoom in too close.  Using triangles will mean the edges won't be smooth, but will look more like a n-gon (eg: octagon) when you zoom in.

HMM

GL_Line_Loop

thinking of something fast to create n sides (its slow to do all with cos and sin) ,
basicly a quarter of a circle, or even maybe 1/8 is enough to get all X,Y positions ... hmm thinking fast routines no (zero) divisions and re-using values, and arrays.


29
Newbie / Darwinbots replacement/clone
« on: April 20, 2010, 05:00:10 AM »
Quote from: Numsgil
Quote from: peterb
Well i've done neither, so i will slowly learn it i guess.

Word of warning: if you've never done any OpenGL/XNA/DirectX before, and don't have a real good understanding of how graphics cards work...  Well, it's going to be difficult.  You're pretty close to the metal.  Basically video cards don't know how to draw anything but triangles.  So for drawing circles you have to either tessellate it (divide it up into triangles) or draw a square with a circle texture.  And there are a lot of ways to do something, only some of which are fast.

Did you see the GDI link I posted at the bottom of my last post?  It's built right in to .NET and I think it'll save you a lot of effort.  It's based more on the "draw circle at x,y pixel position" paradigm you might be used to.

I've seen the GDI sample, they remind me of the pen up and pen down commands of logo, which i never was a fan of..
I've been thinking too to use sprites for circles, that way no calculations..hmm
but they need to rotate as well, and scale not sure if that is something a graphic card does do fast.
Would it be better to scale, or to have multiple sprites of different sizes ?

30
Newbie / Darwinbots replacement/clone
« on: April 19, 2010, 07:41:08 PM »
Quote from: Numsgil
Quote from: peterb
i found some examples here http://nio.astronomy.cz/vb/opengl.html  (which seams fast for a basic aplication),
they use openGL and a wrapper called Tao, which seams to be updated recently
And it doesnt require to install a huge SDK from microsoft, these working demos are pretty small coded.

Tao's also good, yes.  It wraps OpenGL, though, so if you've only done DirectX in the past it's going to be a bit of a learning curve (if you've done neither it's not a big deal).

Quote
OpenGL exists in windows since i think NT3.51 so its pretty stable, and you can upgrade it like directx.
speed diffrences are not huge, so its mainly about how easy it would be to draw lines and circles.

They both get converted by your graphics driver to raw hardware calls.  Though DirectX support tends to be better, especially from ATI.  NVidia does a pretty good job with OpenGL, which is why it's preferred for Linux.

Quote
Hmm if I only could have a picturebox and have it ehmmm like assigned a such openGL power (or directx).
Then I could do all the drawings I want and fast, and then a refresh of the object to show it.
but such a could.. still is a mistery to me.
Its kind of strange we want to draw verry simple, but that seams to require a lot of knowledge these days.

There is still support for basic drawing, as in VB6, through GDI.  This is relevant.  GDI will usually(?) be hardware accelerated, so you still get speed without messing with OpenGL or DirectX.  The downside is that it's not really meant for games and such that update the screen dozens of times a second (but then, the built in VB6 stuff isn't either).


Well i've done neither, so i will slowly learn it i guess.
Ive seen now code to interop c++ also
Maybe a small program can be made using tao,  another wrapper to draw  with a few command only  circle / line / pixel /refresh /clrscr
and have a refresh command so its executed at once.
(or like drawing on a hidden screen part and then the video memory block is switched) , i asume such functions would exist


Pages: 1 [2] 3 4 ... 10