<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3881459760769576454</id><updated>2011-04-21T19:14:45.347-07:00</updated><title type='text'>Evolve</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://evolve-the-balls.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3881459760769576454/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://evolve-the-balls.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Stu</name><uri>http://www.blogger.com/profile/05237190443456827558</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp2.blogger.com/_PsOcfTj0oEg/R9tuZnDbd-I/AAAAAAAAABw/xw0FyoFLxik/S220/CliffsInishMorSmaller.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3881459760769576454.post-4647097539431593873</id><published>2008-03-13T23:08:00.000-07:00</published><updated>2008-03-15T00:00:15.804-07:00</updated><title type='text'>Changes</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_PsOcfTj0oEg/R9oi-HDbd6I/AAAAAAAAABU/LedHXF3RTJE/s1600-h/Screenshot-Stu1.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_PsOcfTj0oEg/R9oi-HDbd6I/AAAAAAAAABU/LedHXF3RTJE/s320/Screenshot-Stu1.png" alt="" id="BLOGGER_PHOTO_ID_5177489172056471458" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;So a lot has happened since the last blog. I stumbled onto to some opportunities, one professional, and one personal, and then stumbled right back out of both of them. While they were both quite alluring, and I tried my hardest to make the best of them, I have to admit I felt some relief with they both fell through. The older I get, the more wary I am of big changes.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;But they were both interesting and challenging, and the professional one got me pouring over my CLR(S), my operating systems book, and topcoder.com. (That last one should be a good hint ;) ). It was nice to go back and dive into the basics. To overview graph algorithms. To read Ingo Molnar's paper on &lt;/span&gt;&lt;a style="font-family: georgia;" href="http://lwn.net/Articles/250967/"&gt;everything a programmer should know about memory&lt;/a&gt;&lt;span style="font-family:georgia;"&gt;. I even flipped through a few pages of Knuth. And in the end, got tripped up on a pointer accounting question. It was a fine time, and forced me to focus on what I wanted to do next. All the algorithms work made me think about where my limits are, and what really gets me excited.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;So, I've started a new phase in the project, with a little different emphasis. The inevitable "dogfood" phase of a software project, where you just get sick of it, and say &lt;/span&gt;&lt;span style="font-style: italic;font-family:georgia;" &gt;I want something that I can use!&lt;/span&gt;&lt;span style="font-family:georgia;"&gt; Or more aptly, &lt;/span&gt;&lt;span style="font-style: italic;font-family:georgia;" &gt;I want something I could show off to someone, if anyone was even conceivably interested in my project! &lt;/span&gt;&lt;span style="font-family:georgia;"&gt;So I put aside all that stuff about dynamically generating function calls at runtime  (since I do have something for making remote requests that currently &lt;/span&gt;&lt;span style="font-style: italic;font-family:georgia;" &gt;works&lt;/span&gt;&lt;span style="font-family:georgia;"&gt;, unlike the front end of the project).  And decided to focus on two other things:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;    -Autoconf'ing the source tree, in order to, if nothing else, just be the same as everybody else. You never really want to make building your program a "unique" experience.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;        -Focusing more effort on the front end, getting more features in the renderer, and tying together all the separate lsystem, physics, and graphics components&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;&lt;br /&gt;I'm very happy to say the autoconf'ing part of the goals are done. Yes, I'm happy that it's all vanilla now. But, no, I didn't have oodles of fun learning all about M4. Still, I like the results, and now that I'm done, they are what matter.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;Now the fun part - where I get to see stuff crawling around on the screen (finally), and breeding, and interacting, and... - I'm happy to say is &lt;/span&gt;&lt;span style="font-style: italic;font-family:georgia;" &gt;not&lt;/span&gt;&lt;span style="font-family:georgia;"&gt; done, but does have some neat features working. This is always one of the best parts of software, you finally got some features that'll put a smile on your face because they actually &lt;/span&gt;&lt;span style="font-style: italic;font-family:georgia;" &gt;work!&lt;/span&gt;&lt;span style="font-family:georgia;"&gt; And you still have a future to be excited about, and features to look forward too.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;So about the obligatory screenshots..&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:georgia;"&gt;The first one (at the top of the article) has no physics enabled, mainly for the sake of generating a pretty screenshot. It shows three trees, all generated from two files. The first containing rules that outline an l-system, it's growth rules, mutation rates, etc:&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;maxSize 100&lt;br /&gt;minSize 10&lt;br /&gt;options L,R,S&lt;br /&gt;system Y&lt;br /&gt;#mutation rules key&lt;br /&gt;#1)the entry is swapped with one of it's neighbors&lt;br /&gt;#2)the entry is toggled to one of it's possible options&lt;br /&gt;#3)the entry is deleted&lt;br /&gt;#4)the entry is doubled&lt;br /&gt;#it is interesting to note that mutations that occur on&lt;br /&gt;#already interpreted elements are essentially irrelevant during growth&lt;br /&gt;#(but not breeding..)&lt;br /&gt;#probability is in 1/10000th&lt;br /&gt;mutationRules (1,3000) (2,2000) (3,3000) (4,100)&lt;br /&gt;growthRules Y:S,S,BL,BR,S,S,BU,SS,BD,SS.BL:[,L,S,S,Y,].BR:[,R,S,S,Y,].BU:[,U,S,S,Y,].BD:[,D,S,S,Y,]&lt;br /&gt;numSteps 0&lt;br /&gt;numSwaps 0&lt;br /&gt;swappedLeft 0&lt;br /&gt;swappedRight 0&lt;br /&gt;numToggled 0&lt;br /&gt;numDeleted 0&lt;br /&gt;numDoubled 0&lt;br /&gt;currentGene 0&lt;br /&gt;&lt;/pre&gt;The second file provides information on how the system should be interpreted:&lt;br /&gt;&lt;pre&gt;LeftAngle -40&lt;br /&gt;RightAngle 50&lt;br /&gt;UpAngle 30&lt;br /&gt;DownAngle -30&lt;br /&gt;Mesh sphere.mesh&lt;br /&gt;StartDirection 0,1,0.1&lt;br /&gt;AtomicSize 10&lt;br /&gt;&lt;/pre&gt;These are both read in at start-up, and the first can be a saved snapshot of the lsystem state at any point in time (not, however, the fully interpreted state, that would be saved via a different component). Keep in mind, too, that all the trees (and the bouncing blobs of balls below), are growing over time. About one new ball pops out of a branch every second or so, up to the max size of the system.&lt;br /&gt;&lt;br /&gt;Here is one with cubes, which makes rendering and getting the screenshot easier on the integrated graphics of my laptop:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_PsOcfTj0oEg/R9oku3Dbd7I/AAAAAAAAABc/gec3KZwiKrU/s1600-h/Screenshot-Stu2.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp2.blogger.com/_PsOcfTj0oEg/R9oku3Dbd7I/AAAAAAAAABc/gec3KZwiKrU/s320/Screenshot-Stu2.png" alt="" id="BLOGGER_PHOTO_ID_5177491109086721970" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;And finally, here's one with physics. It much harder to get this across with a static image, but I haven't figured out how to make a movie yet..&lt;br /&gt;All the balls in each system are joined to their previous ball via a ball joint, and  if I could make a movie, you would see all four systems bounce away from each other, loosely staying together, but each arm swiveling here and there as they move away... It's kinda a neat, but will be even better with hinge joints, and best of all.. motors!&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_PsOcfTj0oEg/R9onAnDbd8I/AAAAAAAAABk/dEbAr3w3T2A/s1600-h/Screenshot-Stu3.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp1.blogger.com/_PsOcfTj0oEg/R9onAnDbd8I/AAAAAAAAABk/dEbAr3w3T2A/s320/Screenshot-Stu3.png" alt="" id="BLOGGER_PHOTO_ID_5177493613052655554" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;On top of all this, I've gotten lasik - totally awesome by the way - I hadn't been able to wear contacts for a year, and suddenly - 20/15 with no glasses!. Plus, they do the whole thing with lasers now,  no microkeratome (little knife) to cut the flap. I'm a Tiger! Well, maybe not that far..&lt;br /&gt;&lt;br /&gt;I also took a trip out east, and wandered around Detroit, DC, and New York, seeing the sites, and meeting up with old friends. It was really wonderful.  It's  a quite journey from West LA out to the snow and chill, but friends make it worth it. And after a few years of being single, a girl asked &lt;span style="font-style: italic;"&gt;me&lt;/span&gt; if I wanted to date. So, while it all started off with some stumbling, I've manged to gradually stumble in the right direction at least. One little change at a time.&lt;br /&gt;&lt;br /&gt;PS..&lt;br /&gt;So right after abandoning the dynamic function bit back in Dec/Jan, I finally stumbled across this: &lt;a href="http://sources.redhat.com/libffi/"&gt;libffi&lt;/a&gt;. When I found it, it seemed pretty much abandoned - the page hadn't been updated in ten years, no documentation, just an old tarball.&lt;br /&gt;&lt;br /&gt;Now, granted, a little digging revealed it's largely maintained by gcc now, and they just updated the site a few days ago (sparking my interest in the whole thing again). However, if you think &lt;span style="font-style: italic;"&gt;I'm&lt;/span&gt; bad at updating my site, and uploading tarballs - Try no updates for ten &lt;span style="font-style: italic;"&gt;years&lt;/span&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3881459760769576454-4647097539431593873?l=evolve-the-balls.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://evolve-the-balls.blogspot.com/feeds/4647097539431593873/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3881459760769576454&amp;postID=4647097539431593873' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3881459760769576454/posts/default/4647097539431593873'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3881459760769576454/posts/default/4647097539431593873'/><link rel='alternate' type='text/html' href='http://evolve-the-balls.blogspot.com/2008/03/changes.html' title='Changes'/><author><name>Stu</name><uri>http://www.blogger.com/profile/05237190443456827558</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp2.blogger.com/_PsOcfTj0oEg/R9tuZnDbd-I/AAAAAAAAABw/xw0FyoFLxik/S220/CliffsInishMorSmaller.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp3.blogger.com/_PsOcfTj0oEg/R9oi-HDbd6I/AAAAAAAAABU/LedHXF3RTJE/s72-c/Screenshot-Stu1.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3881459760769576454.post-8698236452660386838</id><published>2007-09-28T21:26:00.001-07:00</published><updated>2007-09-28T21:52:14.486-07:00</updated><title type='text'>Never say never</title><content type='html'>Well, it's been a while since my last post. Actually, I moved sometime in July, so it's been a while since I had internet at home, let alone posted anything. And I went to Usenix in Boston last month, and visited a friend in Colorado last week. Soo... anyways, I did manage to sneak in one upload of code a week or so ago, and ended up doing exactly what I said wouldn't happen in the last blog post, namely:&lt;br /&gt;&lt;br /&gt;"Sooo, yah, dynamically creating functions - ain't gonna happen."&lt;br /&gt;&lt;br /&gt;Now, granted I gave myself one little loophole:&lt;br /&gt;&lt;br /&gt;"Unless you want to drop into asm and self-modifying code."&lt;br /&gt;&lt;br /&gt;So, basically, I decided I &lt;span style="font-style: italic;"&gt;really&lt;/span&gt; did want to get something like reflection in C++, to avoid the inevitable:&lt;br /&gt;&lt;br /&gt;switch( request )&lt;br /&gt;{&lt;br /&gt;  case 1:&lt;br /&gt;      function 1&lt;br /&gt;  case 2:&lt;br /&gt;      funciton 2&lt;br /&gt;  ....&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; So, what the heck, I thought, I'll try writing some assembly to generate my function calls at runtime. To make a long story short, you create a buffer of machine code, basically your standard "trampoline" code, but on the heap, and call the buffer. The downside is the code needs to be ported if you want to run it on, say, a Mac. The upside is the code is relatively short (should be easy to port). Also, C is flexible enough that the transition from 32 bit -&gt; 64 bit should be a matter of fixing bugs, not rewriting code. Which is good, because I'm writing this blog on my new 64 bit laptop :).&lt;br /&gt;&lt;br /&gt;  The real downside to this code is it can be a pain to debug. Luckily, I've worked with enough asm at this point, so when the debugger just gives up and spits out an address, it actually is giving me useful information. And I thought those asm/computer architecture classes I took so long ago would have no practical applications. Now I use them at work &lt;span style="font-style: italic;"&gt;and&lt;/span&gt; for play. C'est la vie.&lt;br /&gt;&lt;br /&gt;My first rough draft of dynamically generated function calls is up now. Still needs work to round it out, and I still need a way to generate metadata about my classes, so clients can generate requests appropriately (c++2xml?). Anywho, that's it for now.&lt;br /&gt;&lt;br /&gt;cheers!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3881459760769576454-8698236452660386838?l=evolve-the-balls.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://evolve-the-balls.blogspot.com/feeds/8698236452660386838/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3881459760769576454&amp;postID=8698236452660386838' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3881459760769576454/posts/default/8698236452660386838'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3881459760769576454/posts/default/8698236452660386838'/><link rel='alternate' type='text/html' href='http://evolve-the-balls.blogspot.com/2007/09/never-say-never.html' title='Never say never'/><author><name>Stu</name><uri>http://www.blogger.com/profile/05237190443456827558</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp2.blogger.com/_PsOcfTj0oEg/R9tuZnDbd-I/AAAAAAAAABw/xw0FyoFLxik/S220/CliffsInishMorSmaller.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3881459760769576454.post-6728231393012146227</id><published>2007-07-15T21:33:00.000-07:00</published><updated>2007-07-18T01:02:19.792-07:00</updated><title type='text'>Reflections</title><content type='html'>&lt;p&gt;Well, not a whole lot of coding happened this week. But I did see &lt;a href="http://www.hollywoodbowl.com/tix/performance_detail.cfm?id=3225"&gt;Tchaikovsky with fireworks&lt;/a&gt; Tues night. And the cops did show up at my door at 2am on Thurs, banged on it for awhile, and then wouldn't tell me why when I asked. *sigh*. LAPD. But the fireworks were really nice, and I hope to get pictures from one of my co-workers. That'll be my screenshot for this week :)&lt;br /&gt;&lt;br /&gt;Anyways, I finally realized what I really needed to expose my objects interfaces was reflection. At first I had the fuzzy idea that maybe I could just map ids -&amp;gt; function pointers, but once I refreshed myself on function pointers in C++, I realized it just can't happen. Because you need something like this: &lt;/p&gt;&lt;pre&gt;&lt;span style="font-size:12;"&gt;map&amp;lt;string,funcPointer*&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;Where funcPointer can point at whatever function you want. Like Python :) But C++ makes you declare the args along your function pointer. At first I was like "Oh, there's probably a work around". Usually C++ has &lt;span style="font-style: italic;"&gt;some&lt;/span&gt; sort of way of letting do what you want, if you really want to do it. I mean, just the keyword "friend" lets you violate encapsulation in all kinds of interesting ways. But then I ran across an erroneous statement somewhere along the lines of "function pointers aren't like normal pointers, they hold some extra information". My realization came in three states:&lt;br /&gt;&lt;/p&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Oh!, ok...&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Wait, no, bullocks!&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Hmm.. ok they're wrong, but I know what they mean, or a least what they repeated incorrectly&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;p&gt;The Oh!, ok.. speaks for itself. The "Wait, no... bollocks!" comes from the fact that I look at a lot of disassembly in my line of work, and I realized that no, a function pointer is just an address, like any other pointer. A function call using a pointer is just going to look something like this:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;&lt;span style="font-size:12;"&gt;call [address]&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;And that can even be broken into:&lt;/p&gt;&lt;pre&gt;&lt;span style="font-size:12;"&gt;push eip+5&lt;br /&gt;jump [address]&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;(jump is one byte, address is four, this is on a x86).&lt;br /&gt;Hmm. So what's this business about "A function pointer has extra info"? Well, what they should have said is a function pointer &lt;span style="font-style: italic;"&gt;declaration&lt;/span&gt; has extra info, namely, what arguments to push on the stack. This information is used by the compiler, and has nothing to do with the run-time encoding of function pointers. For a compiled language, figuring out what to push and pop on the stack pretty much has to happen at compile time. Unless you want to drop into asm and self-modifying code. Sooo, yah, dynamically creating functions - ain't gonna happen. RTTI is _not_ going to somehow magically create:&lt;/p&gt;&lt;pre&gt;&lt;span style="font-size:12;"&gt;push c&lt;br /&gt;push b&lt;br /&gt;push a&lt;br /&gt;call [address]&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;Just because it likes you.&lt;br /&gt;In a statically compiled language, the only way you could do that is to have your arguments on the heap, not the stack. Oh well.... Or not?&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Well, maybe there is a little wiggle room with that whole heap business. We could expose a function like:&lt;/p&gt;&lt;pre&gt;&lt;span style="font-size:11;"&gt;invoke( string funcSpecification, void* args, void* reply )&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;Of course, now we have the whole messy business of, badabum:&lt;/p&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;A means to specify and expose functions&lt;/li&gt;&lt;br /&gt;&lt;li&gt;A standard way to parse and create those "void* args, void* reply" arguments&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;p&gt;In other words, the same questions as my last post, but further along ;) Or Progress! Yes, the nagging first item: you do something highly structured and and formal like xml (WSDL), and it's just a bitch to specify everything, and send it across the network. But you have a nice standard parser, and a clear structure. You do something loose and custom, and you have wonky stuff like the IDL that just invents a new language, and not necessarily a good one.. So I think I'm going to start off having the objects expose something wonky like:&lt;br /&gt;&lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style="font-size:11;"&gt;vector&lt;string&gt; reflection;&lt;br /&gt;reflection.push_back("getData( string, int )=myDataType")&lt;br /&gt;&lt;/string&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;to a library that gets loaded by the server. This library can load and generically manage any object that has the method vector&lt;string&gt; getReflection() and invoke( string id, void* args, void* reply), and a little parsing logic... Clients will get something nicer and more structured from the server. Possibly even something that can be used to generate code. So not much different than the current setup. With one big difference: (1) that's _one_ library can manage any object with the right interface, instead of having a different library wrap every object. Yuck.&lt;br /&gt;&lt;/string&gt;&lt;/p&gt;&lt;p&gt;So what about that second point?&lt;/p&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;A standard way to parse and create those args,reply arguments&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;p&gt;Why my friends. That's just serialization! :)&lt;/p&gt;&lt;br /&gt;&lt;p&gt;One final reflection: an interesting effect of coding late at night, after you get home from work, is that it leads to things like this:&lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style="font-size:11;"&gt;template&amp;lt;class T&amp;gt;&lt;br /&gt;    bool serialize( T data, char*&amp; state, unsigned int&amp; size )&lt;br /&gt;    {&lt;br /&gt;        if( typeid( T ).name() == typeid( string ).name() )&lt;br /&gt;        {&lt;br /&gt;            //go ahead and give it to'm&lt;br /&gt;            cout &amp;lt;&amp;lt; "String!" &amp;lt;&amp;lt; endl;&lt;br /&gt;            return serializeString( data, state, size );&lt;br /&gt;        }&lt;br /&gt;        if( sizeof(T) &amp;gt; INT_MAX )&lt;br /&gt;        {&lt;br /&gt;            cout &amp;lt;&amp;lt; "Data type way too big" &amp;lt;&amp;lt; endl;&lt;br /&gt;            return false;&lt;br /&gt;        }&lt;br /&gt;        state = new char[sizeof(T)];&lt;br /&gt;        size = sizeof(T);&lt;br /&gt;    &lt;br /&gt;        //this is kind of silly, but a byte isn't always 8 bits,&lt;br /&gt;        //so we can't just say tmp &amp; 0xFF below&lt;br /&gt;        //I really can't believe I bothered to handle this case.&lt;br /&gt;        //However, this loop _is_ worth it just to think of the C coders screaming bloody murder&lt;br /&gt;        //and pounding their heads in the desk&lt;br /&gt;        char mask = 0x0; //a char is always 1 byte though&lt;br /&gt;        for( int i = 0; i &amp;lt; CHAR_BIT; ++i )&lt;br /&gt;        {&lt;br /&gt;            mask = (mask &amp;lt;&amp;lt; 1) | 0x01; &lt;br /&gt;        }&lt;br /&gt;        //index needs to handle negative so we can count down, no unsigned int&lt;br /&gt;        for( int i = sizeof(T) - 1; i &amp;gt;= 0; --i )&lt;br /&gt;        {&lt;br /&gt;            T tmp = data &amp;gt;&amp;gt; i * CHAR_BIT; &lt;br /&gt;            state[i] = tmp &amp; mask;         &lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;/class&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Then you come home the next night and realize that what you really meant was:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&lt;span style="font-size:8;"&gt;&lt;br /&gt;   template&amp;lt;class T&amp;gt;&lt;br /&gt;   bool serialize( T data, char*&amp; state, unsigned int&amp;amp; size )&lt;br /&gt;   {&lt;br /&gt;       size = sizeof(T);&lt;br /&gt;       state = new char[size];&lt;br /&gt;       memcpy( state, (void*)&amp;data, size );&lt;br /&gt;   }&lt;br /&gt;&lt;/class&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Nothing like a good nights sleep!&lt;br /&gt;&lt;br /&gt;Cheers!&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;PS. Blogger sucks at trying to put code up. Try Ctrl-Shift-+.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3881459760769576454-6728231393012146227?l=evolve-the-balls.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://evolve-the-balls.blogspot.com/feeds/6728231393012146227/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3881459760769576454&amp;postID=6728231393012146227' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3881459760769576454/posts/default/6728231393012146227'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3881459760769576454/posts/default/6728231393012146227'/><link rel='alternate' type='text/html' href='http://evolve-the-balls.blogspot.com/2007/07/reflections.html' title='Reflections'/><author><name>Stu</name><uri>http://www.blogger.com/profile/05237190443456827558</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp2.blogger.com/_PsOcfTj0oEg/R9tuZnDbd-I/AAAAAAAAABw/xw0FyoFLxik/S220/CliffsInishMorSmaller.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3881459760769576454.post-7794992787625729491</id><published>2007-07-06T23:08:00.000-07:00</published><updated>2007-07-06T23:47:30.896-07:00</updated><title type='text'>Smokin'</title><content type='html'>The smoke test is back, and using the ogre renderer. But the important thing is all the components are working together again. So now it's time to break stuff! &lt;br /&gt;&lt;br /&gt;There's two major things I'm looking at:&lt;br /&gt;&lt;br /&gt;- Simplify message passing.&lt;br /&gt;&lt;br /&gt;   I plan to do this by implementing object serialization for my hierarchy. I have to be careful, but I think I know how to do this. It might take some time, but it shouldn't be too bad.&lt;br /&gt;  &lt;br /&gt;- Exposing the interfaces of server-managed objects.&lt;br /&gt;&lt;br /&gt;  This is harder, and I'm just looking at mechanism right now, not even policy. The current deal is every method matches up with a command in the Commands object. Commands are specified in an xml file, and code is generated from them. Each command requests certain data, and has an expected response. Requests and responses are specified in xml files, and client interface code is generated from them. On the server, each object is wrapped in a shared library that can be loaded by the server depending on what behavior you want the server to take on. Each shared libary exposes the same interface to the server object - handleCommand( id, command ) I WANT SOMETHING SIMPLE! Oy. Or at least more transparent on the client end, and less work on the server end. Yes, I know this is an old problem with corba, rmi, soap, etc, littering the path before me. So this problem is harder :|&lt;br /&gt;&lt;br /&gt;But that's what makes it fun! :)&lt;br /&gt;&lt;br /&gt;Screenshots...&lt;br /&gt;Unfortunately, I couldn't dig up some of the neater patterns I used to have, but they do demonstrate 3D hierarchal lsystems. The second has breeding turned on, so it looks a little more messed up.&lt;br /&gt;  &lt;br /&gt; &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_PsOcfTj0oEg/Ro80JCUTqyI/AAAAAAAAABE/WzpCp9GtNrk/s1600-h/smoke2a.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp0.blogger.com/_PsOcfTj0oEg/Ro80JCUTqyI/AAAAAAAAABE/WzpCp9GtNrk/s320/smoke2a.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5084339834170092322" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_PsOcfTj0oEg/Ro80JiUTqzI/AAAAAAAAABM/xwAfLpWEjcc/s1600-h/smoke2b.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp2.blogger.com/_PsOcfTj0oEg/Ro80JiUTqzI/AAAAAAAAABM/xwAfLpWEjcc/s320/smoke2b.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5084339842760026930" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3881459760769576454-7794992787625729491?l=evolve-the-balls.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://evolve-the-balls.blogspot.com/feeds/7794992787625729491/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3881459760769576454&amp;postID=7794992787625729491' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3881459760769576454/posts/default/7794992787625729491'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3881459760769576454/posts/default/7794992787625729491'/><link rel='alternate' type='text/html' href='http://evolve-the-balls.blogspot.com/2007/07/smokin.html' title='Smokin&apos;'/><author><name>Stu</name><uri>http://www.blogger.com/profile/05237190443456827558</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp2.blogger.com/_PsOcfTj0oEg/R9tuZnDbd-I/AAAAAAAAABw/xw0FyoFLxik/S220/CliffsInishMorSmaller.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp0.blogger.com/_PsOcfTj0oEg/Ro80JCUTqyI/AAAAAAAAABE/WzpCp9GtNrk/s72-c/smoke2a.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3881459760769576454.post-1510273542877996840</id><published>2007-06-26T23:01:00.000-07:00</published><updated>2007-07-02T00:57:12.825-07:00</updated><title type='text'>Bouncing Ninjas!</title><content type='html'>So after trying OpenGL + ODE, Irrlicht + ODE, I've finally settled on &lt;a href="http://www.ogre3d.org/"&gt;OGRE&lt;/a&gt; + &lt;a href="http://www.ode.org/"&gt;ODE&lt;/a&gt; + ? for the client rendering/smoke tests. &lt;br /&gt;&lt;br /&gt;A little history.&lt;br /&gt;A little while ago, after getting the lsystem, system server, interpreter, interpreter server, and my OpenGL + ODE client all displaying lsystems that were interpreted as 3D points in space, and could be evolved (via mutations and cross-breeding), I began to run up against the limits of how much time I could put into OpenGL. So I began looking for a 3D toolkit I was happy with. OGRE is it. However, now I need to find an input system I'm happy with. OIS is not it, and SDL may be it, but the OGRE codebase has drifted ever more and accomodating OIS/CEGUI, so that's what I'm using for now. I had SDL integrated in, but pulled it.&lt;br /&gt;&lt;br /&gt;But for now, I'm eager to get back to fixing all the bugs I've found in the other components: subtle issues with mutexes, simplifying message passing (I'm not scared of hex anymore, so I'm going to make the objects serialize themselves instead of the current mess). And I'll just be glad to see those 3D l-systems again (especially coz I can't find any screenshots to prove I did it). For now, here's some screenshots of bouncing ninjas, and 2D systems generated from a codebase that has since been pretty much re-written.&lt;br /&gt;&lt;br /&gt;Enjoy!&lt;br /&gt;&lt;br /&gt;Ninjas:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_PsOcfTj0oEg/RoICJCUTqrI/AAAAAAAAAAM/9jPSpqGOIUg/s1600-h/Screenshot-ninjas.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp3.blogger.com/_PsOcfTj0oEg/RoICJCUTqrI/AAAAAAAAAAM/9jPSpqGOIUg/s320/Screenshot-ninjas.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5080625683891464882" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Trying to see how big I could make the system (something like 100K elements/spheres in this one)&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_PsOcfTj0oEg/RoIDLSUTqsI/AAAAAAAAAAU/MZrT3Nk3I6Y/s1600-h/LSystemBig.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp0.blogger.com/_PsOcfTj0oEg/RoIDLSUTqsI/AAAAAAAAAAU/MZrT3Nk3I6Y/s320/LSystemBig.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5080626822057798338" /&gt;&lt;/a&gt;&lt;br /&gt;Detail:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_PsOcfTj0oEg/RoIDLiUTqtI/AAAAAAAAAAc/sOl7yzFGWRM/s1600-h/LSystemSmall.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp1.blogger.com/_PsOcfTj0oEg/RoIDLiUTqtI/AAAAAAAAAAc/sOl7yzFGWRM/s320/LSystemSmall.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5080626826352765650" /&gt;&lt;/a&gt;&lt;br /&gt;Systems with the same start state, but one has a mutation rate &gt; 1.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_PsOcfTj0oEg/RoIDLyUTquI/AAAAAAAAAAk/0L3K733pGUs/s1600-h/LSystemMutationCompare1.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp2.blogger.com/_PsOcfTj0oEg/RoIDLyUTquI/AAAAAAAAAAk/0L3K733pGUs/s320/LSystemMutationCompare1.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5080626830647732962" /&gt;&lt;/a&gt;&lt;br /&gt;Playing around with different settings:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_PsOcfTj0oEg/RoIDMSUTqwI/AAAAAAAAAA0/03S7DEVR-9Y/s1600-h/LSystemTestRun.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp0.blogger.com/_PsOcfTj0oEg/RoIDMSUTqwI/AAAAAAAAAA0/03S7DEVR-9Y/s320/LSystemTestRun.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5080626839237667586" /&gt;&lt;/a&gt;&lt;br /&gt;Bouncing Ninjas Refactored!&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_PsOcfTj0oEg/RoivniUTqxI/AAAAAAAAAA8/NkoPvFQ7ofk/s1600-h/bouncing2.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="http://bp3.blogger.com/_PsOcfTj0oEg/RoivniUTqxI/AAAAAAAAAA8/NkoPvFQ7ofk/s320/bouncing2.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5082505273249344274" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3881459760769576454-1510273542877996840?l=evolve-the-balls.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://evolve-the-balls.blogspot.com/feeds/1510273542877996840/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3881459760769576454&amp;postID=1510273542877996840' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3881459760769576454/posts/default/1510273542877996840'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3881459760769576454/posts/default/1510273542877996840'/><link rel='alternate' type='text/html' href='http://evolve-the-balls.blogspot.com/2007/06/bouncing-ninjas.html' title='Bouncing Ninjas!'/><author><name>Stu</name><uri>http://www.blogger.com/profile/05237190443456827558</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp2.blogger.com/_PsOcfTj0oEg/R9tuZnDbd-I/AAAAAAAAABw/xw0FyoFLxik/S220/CliffsInishMorSmaller.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://bp3.blogger.com/_PsOcfTj0oEg/RoICJCUTqrI/AAAAAAAAAAM/9jPSpqGOIUg/s72-c/Screenshot-ninjas.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3881459760769576454.post-6515549579682514950</id><published>2007-06-26T22:42:00.000-07:00</published><updated>2007-06-26T22:58:36.363-07:00</updated><title type='text'>Intro</title><content type='html'>Hello, this is my blog about my &lt;a href="http://code.google.com/p/evolve-the-balls/"&gt;project&lt;/a&gt;. I noticed I kept updating the intro page, and realized one day I'd want screenshots, musings and such. So I turned to this. &lt;br /&gt;Maybe I'll even get around to sketching out the design in something other than code one day, and post it ;). &lt;br /&gt;For now, the current status: &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Cons&lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Currently &lt;span style="text-decoration: line-through"&gt;broken&lt;/span&gt; only has some working components (servers, lsystem, some physics).And bouncing ninjas! &lt;/li&gt;&lt;br /&gt;&lt;li&gt;Undergoing a lot of rework.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;At the very least depends on Boost, ODE.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Client will depend on OGRE.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Client may end up depending on GDK/SDL, but currently trying OIS instead of SDL.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;I currently don't like OIS, but I need to focus on other things.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;SDL code written but pulled out temporarily.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Currently only works on linux. I don't have windows to do the port (but I keep it in mind).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;No Design/Overview documentation.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Some of the design kind of sucks.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Pros&lt;/b&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Has had all the parts working together in the past.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Some of the design is kind of nice.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;platform dependencies are wrapped/abstracted.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Build system is simple and straightforward. No automake/m4 magic.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;I always kept it moving forward, albeit often slowly, with long pauses, and many rewrites, over the last few years.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3881459760769576454-6515549579682514950?l=evolve-the-balls.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://evolve-the-balls.blogspot.com/feeds/6515549579682514950/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3881459760769576454&amp;postID=6515549579682514950' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3881459760769576454/posts/default/6515549579682514950'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3881459760769576454/posts/default/6515549579682514950'/><link rel='alternate' type='text/html' href='http://evolve-the-balls.blogspot.com/2007/06/intro.html' title='Intro'/><author><name>Stu</name><uri>http://www.blogger.com/profile/05237190443456827558</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp2.blogger.com/_PsOcfTj0oEg/R9tuZnDbd-I/AAAAAAAAABw/xw0FyoFLxik/S220/CliffsInishMorSmaller.jpg'/></author><thr:total>0</thr:total></entry></feed>
