Spaces Between
sidebar left sidebar right

In the garden II

Sequel to In the Garden. This time it’s all about some of the indoor plants, all these are carnivorous and trap prey either by pitfall, sticky tentacles, or gummy, gooey, leaves.

 

The giant Nepenthes I got last summer is even more giant now. The plant has doubled in size to over 130cm (4.5 ft). Here is the first new trap. It turns out that this plant is likely Nepenthes Miranda, a hybrid of obscure origin, but recently popular as someone has figured out how to efficiently propagate them. You can see part of my Natural History museum/Wunderkammer in the background - my wife’s sculpture of a sea dragon, a sustainably collected butterfly, an AT-AT, and a first generation plaster cast of Archaeopterix Lithographica, pulled by a paleontologist friend from the original in Berlin.

 

 

Part of the jungle.

 

 

These are miniature Drosera, the spindly ones in the back are Scorpiades.

 

 

The Pinguicula farm. If you have a look at the earlier post, that large “octopus plant” has multiplied into ten plants filling the huge pot in the foreground. The plants in the background just got separated out from the pot in the white saucer on the right. How did they all cram in there? I am amazed at how shallow the roots are; these guys just sit on top of the soil more or less. In the terrarium you can see a ping pot my wife made for me with a nice ping sculpture on the side.

The bright blue ball is a polished fused ball of glass fibers.

Amazon Recommends

Amazon recommended The Force Unleashed to Tara. I went and had a peek at what games it had to recommend for me… Hmmm, an endless parade of Final Fantasy variations, Harvest Moon games, and Metal Gear Solid. How did that happen?!

I’ll have to seed the results a bit, and link what I want to see from here!

Here’s the X360 - Star Wars: The Force Unleashed

And the PS3 - Star Wars: The Force Unleashed

Action figures,

A light saber with spring loaded Sith spikes,
Star Wars Force Unleashed Deluxe Lightsaber

An amazingly cool Art Of book - it’s the first time I’ve been mentioned in an Art Of book, I can hardly wait to get a copy! The art team on this game was simply amazing, the book is a blast.

The Art and Making of Star Wars: The Force Unleashed (Star Wars)

And last, but not least, a Lego Rogue Shadow:

This game has the most awesome merchandising of any I’ve ever worked on. Lego!

Walter Murch

My team mates and I designed and built an audio engine around the theories of Walter Murch*, the innovative sound designer, for our most recent game. Amazingly, and coincidentally, I got to spend an hour at lunch with him last summer. At the time I didn’t know who he was, just that he was very interesting and astute. After he got up and left, someone mentioned who he was. I’m kind of glad I didn’t know at the time, because not knowing let me carry on a normal conversation!

There’s a fantastic interview here:

http://www.transom.org/guests/review/200504.review.murch.pdf

* I’ll refer you to the imdb page for his filmography, it’s an astonishing oeuvre.

Scenius

Kevin Kelly has posted “Scenius“, a concept suggested by Brian Eno to suggest the creativity embedded in groups. The characteristics of scenius are -

  • Mutual appreciation - Cool ideas and people buoy each other
  • Rapid exchange of tools and techniques - new ideas are flaunted and shared
  • Network effects of success - success is celebrated as mutual, and of the group
  • Local tolerance for novelties - space for crazy and novel solutions to grow

After reading Kevin’s post, I’ve got to say I’ve been blessed my entire working career to find myself with rockin’ peers.

A simple Type mechanism for the Smallest Attribute System

The Smallest Attribute System (part 1, part 2) is almost done. This article presents a simple type mechanism that for eliminating the need for using C++ run time type information (RTTI). This modification is necessary because some compilers, especially on game consoles and embedded systems, don’t generate RTTI. The last piece, still to come, is reading and writing attributes from a file.

An int or short can be substituted for the typeid in the Smallest Attribute System. The version presented here is self-priming; an identifier for a type is generated whenever a type is first requested by name. The next time the same type is requested, the generated id will be returned.

class CharPtrPredicate
{
public:
    bool operator()(char const*const& lhs, char const*const& rhs) const
    {
        return strcmp(lhs, rhs) < 0;
    }
};

static std::map<const char*, int, CharPtrPredicate> typeIds;
static std::map<int, const char*> typeNames;

// If a type hasn’t been seen before, enumerate it, otherwise return
// the enumerant generated the first time it was seen

int GetTypeId(const char* type)
{
    static int unique = 0;
    std::map<const char*, int, CharPtrPredicate>::const_iterator i = typeIds.find(type);
    int result;
    if (i == typeIds.end())
    {
        typeIds[type] = unique;
        typeNames[unique] = type;
        result = unique;
        ++unique;
    }
    else
    {
        result = i->second;
    }
    return result;
}

// GetTypeId must have been called for every type for this to return a useful value.

const char* GetTypeName(int i)
{
    std::map<int, const char*>::const_iterator j = typeNames.find(i);
    return j == typeNames.end() ? 0 : j->second;
}

The TypeName method needs to be updated.

std::string AttributeBinder::AttributeDescriptor::TypeName() const
{
    return GetTypeName(typeId);
}

Routines that use a particular type should statically initialize their variables to avoid map lookups later. For example:

    static int stringType = GetTypeId(“std::string”);

    if      (typeId == intType)
        o << “Found an int”;

Finally modify the AttributeBinder to store an int as a typeId, instead of the type_info of the original class. The BIND macro needs to be modified as follows, everything else is pretty much the same.

#define BIND(className, val, vartype) \
    binding.bind(#val, #vartype, (ptrdiff_t)&((className*)0)->val)

Wordle.net is nifty


Wordle.net is nifty. I created the image above by loading wordle.net up with the text of my article on AI. I did another one for my Content pipeline page. Pretty fun!

Best of Game Programming Gems

My chapter on writing a Verlet Physics Engine has been reprinted. Thanks Mark, for selecting my chapter for inclusion - I’m pleased to be in this august company of authors!

Best of Game Programming Gems

Smallest Useful Attribute System Part 2

Reader Alexey provided some useful feedback on The Smallest Useful Attribute System. The first point I want to address is the extra copies of strings. When I embedded the strings in the map and the AttributeDescriptor, I had been thinking that if the strings were part of a DLL, and the DLL got unloaded, there would be trouble. On further reflection, it occurred to me that I had over-thought it. If a DLL got unloaded, and then one attempted to fetch attributes on the now dead classes, there are bigger problems going on. So, here’s the fix to the string copies; we go from one static string built into the data and two dynamic copies to just the static string.

class AttributeBinder
{
…snip…
    class AttributeDescriptor
    {
…snip…
        AttributeDescriptor(const char* name, const std::type_info& ti, ptrdiff_t off) :
            name(name), ti(&ti), off(off) { }
        const char* name;
…snip…
    };

    class Predicate
    {
    public:
        bool operator()(char const*const& lhs, char const*const& rhs) const
        {
            return strcmp(lhs, rhs) < 0;
        }
    };

    std::map<const char*, AttributeDescriptor, Predicate> attribs;
};

The std::string has been replaced by const char*, and the map is supplied with an ordering predicate that does the comparisons from the name of the attribute.

Click to read the original post: The Smallest Useful Attribute System.

Robofish

It’s been years since I worked on autonomous submarines, but underwater robotics still turn my crank. Gizmodo has an article on work at the University of Washington carried out in the lab of Kristi Morgansen. I am particularly keen on the design of their robot; the pectoral fins are actuated by microlite servos, the rear of the fish is activated by a high speed servo, and the tail fin is driven by a high-torque micro motor.

This sort of design should yield higher maneuverability, and greater mechanical efficiency through reduced cavitation and drag. Of course fish have already proven the superiority of this sort of an arrangement! A useful contribution of their research is that they’ve derived a general mathematical framework for controlling robots that propel themselves by changing their shape.

Their current tests involve trying to make the fish school using very simple communication, and very simple commands, such as “swim in the same direction as me.” The theoretical and practical groundwork for this flocking, schooling, and herding was laid by Craig Reynolds back in 1987. It will be cool to see a physical embodiment of Boids!

Smallest possible useful C++ Attribute system?

Over the years, I’ve seen almost as many attribute reflection systems as I’ve worked on games, and that’s a lot of games. This article by Gary McNickle on Gamasutra is clean and easy to read, but it is not as small as possible. It inspired me to write a few notes about how I think these things should be put together.

Here are the usage goals for the system:

  • The game code owns the variables, not the attribute system
  • The attribute system does not force the game to use it
  • Attributes can be searched, and iterated over

Out of scope:

  • Serialization to disk, and relocation
  • Implementation of features normally part of C++ or the STL

Here are some technical requirements I decided to hit:

  • Only one copy of any name of any variable would ever be stored
  • As much as possible the system will self-priming
  • The system will be typesafe
  • Methods on the class may be templated for convenient type coercion
  • Avoid “best practices” such as accessors if they don’t make the code simpler

I tried several variations, and each one got shorter and less complex. I started with a template meta-programmed solution, not unlike the cleverness referenced by Gary in the Boost spirit library. The next version stripped this down to a much simpler templated attribute system; I simplified that through two rewrites. At first I pursued a template based system because the code tends to be easier to read than piles of preprocessor mess. I have a bit of a distaste for macro based systems because they tend to become unwieldy and difficult to maintain as features get wedged into the system, whereas template code remains legible. After some thought it occurred to me that if one kept the attribute system trivially simple, the macros could remain trivially simple. Templates could be used at a higher level than the base objects to implement the complexity. At this point, I overcame my built-in distaste for macro-based attribute systems, and came up with the smallest useful system I could think of.

In real life, I would not use std::string, but rather a block of data containing the char data, and indexed by offsets. Blocks of data indexed by offsets are easy to relocate to keep memory compact, and are trivial to cache of to disk. This approach also avoids the constant overhead of a string object (which tends to be 32 bytes), and also avoids any small allocations from the heap (a string takes two).

Also, I would think carefully about the use of std::map, to make sure it does not impact run time performance. A sure sign that an STL map of std::string is a poor choice is if profiling shows a measurable amount of time being spent in string comparisons.

I wonder if this can be made smaller?

 

#include <typeinfo.h>
#include <string>
#include <map>

class AttributeBinder
{
public:

    class AttributeDescriptor
    {
    public:
        AttributeDescriptor() : ti(0), off(0) { }

        AttributeDescriptor(const char* name, const std::type_info& ti, ptrdiff_t off) :
            name(name), ti(&ti), off(off) { }

        AttributeDescriptor(const AttributeDescriptor& rhs) :
            name(rhs.name), ti(rhs.ti), off(rhs.off) { }

        std::string name;
        ptrdiff_t off;

        bool typeEqual(const AttributeDescriptor& rhs)
        {
            return *ti == *rhs.ti;
        }

    private:
        // note, must compare type infos by *m_pInfo == *rhs.m_pInfo
        // because the pointers might not be the same, even if the types are
        const std::type_info* ti;
    };

    void bind(const char* varname, const std::type_info& ti, ptrdiff_t offset)
    {
        attribs[varname] = AttributeDescriptor(varname, ti, offset);
    }

    std::map<std::string, AttributeDescriptor> attribs;
};


// Within a class, create a binding object, and start the Bind method.
// Note that it is valid to put other code between BIND_START and BIND_END
// if you want it to run during the static Bind initialization.
// Semicolons are optional after BIND_START, you can use them if you use
// a pretty-printer on code and want things to line up nicely

#define BIND_START \
    static AttributeBinder binding; \
    static void Bind() \
{ \

// Bind a single variable

#define BIND(c, v, t) \
    binding.bind( #v, typeid(t), (ptrdiff_t)&((c*)0)->v)

// End the bind method
// Semicolons are optional after BIND_END, you can use them if you use
// a pretty-printer on code and want things to line up nicely

#define BIND_END \
}

// Instantiate the binding object for class C, and make a globally
// instantiated struct whose constructor will invoke C’s Bind method
// which has been declared in BIND_START
// This goes in the implementation file, in the same namespace as the
// class C.

#define BIND_ATTRIBUTES(c) \
    AttributeBinder c::binding; \
    namespace { \
        struct Static ## c ## Binder \
        { \
            Static ## c ## Binder() { c::Bind(); } \
        }; \
        static Static ## c ## Binder static ## c ## binder; \
    }

And here’s an example of decorating a class:

 

class Foo
{
public:
    BIND_START;
    BIND(Foo, myInt,    int);
    BIND(Foo, myFloat,    float);
    BIND(Foo, bar,        float);
    BIND_END;

    Foo() : myInt(1), myFloat(2), bar(3)
    {
    }

    int myInt;
    float myFloat;
    float bar;
};

BIND_ATTRIBUTES(Foo);

 

Finally, to look up a variable, you would use your privileged knowledge of the implementation to do something like the following:

    Foo myFoo;
    // looking up myInt
    std::map<std::string, AttributeBinder::AttributeDescriptor>::const_iterator i =
        Foo::binding.attribs.find(“myInt”);

    // reading the int
    int intVar = *(int*) (ptrdiff_t)&myFoo + i->second.off;

    // writing the int
    *((int*) (ptrdiff_t)&myFoo + i->second.off) = 3;

 

This can be prettied up with simple templated member functions, but I leave that as an exercise to the reader.

Galactic Map

Nasa has posted the most accurate face-on map of our galaxy yet, including new discoveries such as the “Far 3 Kiloparsec Arm”. The galaxy was previously thought to have four arms, but the latest survey from the orbiting Spitzer telescope reveals that the galaxy is two armed bar spiral. Darth Mojo has an entertaining piece on the Spitzer data including a picture of how big an iPhone would have to be to display all the data at once!

I guess the old Karl Sims Panspermia video must show the genesis of life in a different galaxy, I always thought it was ours.

Stellar Flash

Via BLDG BLOG, an amazing sequence of shots captured by the Hubble Telescope in 2002. V838 Monocerotis briefly became the brightest star in the Galaxy; as its luminosity increased, its gaseous surroundings were illuminated as the light wavefront traveled through it.

Beautiful high resolution images are available from the Hubble archive site.

 

  

V838 Monocertos is located here:

Tormenta eléctrica en erupción del volcán Chaitén

The title says it all. I found some amazing images taken by Carlos Gutierrez at this gallery via BLDGBLOG. According to NewScientist, low-energy lightning arcs between charged particles venting from the volcano’s mouth.

Futurist Programming 2.2

No Compromise, No Waste Programming

  • The program is the BEST at what it does
  • The program is FAST
  • The footprint is SMALL
  • The code is CLEAR
  • The program is as BUG-FREE
  • Abstractions must SIMPLIFY
  • The unnecessary is ELIMINATED

NO COMPROMISES in the name of Extensibility, Modularity, Structured Programming, Reusable Code, Top Down Design, Standards, Object Oriented Design, or Agility.

Version 2.1

Broken Abstraction

From Senzee 5:

The primary reason for abstraction is to simplify implementation for a given set of requirements.
If abstraction doesn’t simplify, ditch it.

I’m thinking it might be time for an upgrade to Futurist Programming.

meshula.net is powered by WordPress

Bad Behavior has blocked 575 access attempts in the last 7 days.

No Complaints Shifter Series Theme by Buzzdroid.com