Deprecated: Assigning the return value of new by reference is deprecated in /home/ina/public_html/blog/wp-includes/cache.php on line 36

Deprecated: Assigning the return value of new by reference is deprecated in /home/ina/public_html/blog/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/ina/public_html/blog/wp-includes/theme.php on line 540
Blog by Ina Centaur » bots


A Casual Meditation on Life from the Creation of Virtual Bunnies

Written by ina on Wednesday, 13 of January , 2010 at 1:04 am
Tags: , , ,

I. Exordium

What is a living creature? It responds to things, and it multiplies. From the perspective of computing, it’s an entity that is capable of input and output, with a manner of self-propagation.

Ah, propagation… Therein lies the interesting element–the growth of a population. Consider a hypothetical case, where you start out on a desert island with a pair of male and female creatures; each female produces just one female offspring per generation, and stops reproducing after two generation. Assume the male is immortal, and massive incest occurs to create all subsequent generations, all females. The heritage diagram of sorts would look something like this:


Or, referencing the same diagram, but slightly more organized, and not-too-snobby-against-the-color-blind (thanks to @WildstarB):


To make it more interesting, Fibonacci, from back in the day, thought of the same problem. Apparently, bunnies were the most nearly-instantly promiscuous creatures back then, so his gedanken involved bunnies, and he devised the eponymous Fibonacci Sequence using the generation scheme described above (though, he didn’t use an immortal male, but rather, the assumption that each female produces a male and female pair per generation, with guaranteed brother-sister incest).

This is just an interesting thought experiment of an extremely basic model for describing population growth that, other than using bunnies as our key sex players, has absolutely nothing related to the virtual bunnies to be discussed in the rest of this article.

The point is that living creatures, in addition to responding to stimuli, have internal mechanisms of sorts that enable its reproduction. At least, that’s the perspective of a living creature that we have from observing its behavior from our limited microcosm. Microcosm? Habitat?

We’re actually right on topic, heading onto the most basic features of creating a virtual critter with AI-esque–certainly necessary for the creation of the virtual bunnies that piqued up your interest.

II. The Pseudo-Physics of Our Subset of the Virtual Microcosm

In “RL”, when you drop a ball, it falls, and when it hits a flat surface, it stops falling (though it might bounce or roll or crack or explode, or do a number of things in reaction to this action of collision). In “SL” or any virtual reality, when you drop a ball, it might not do any of those things, or it might do all of those things, depending on what you program the “physics” of your virtual microcosm to be. The essential affect is the reaction to an action–what happens when the collision (or, in general, the interaction among separate entities) occurs. In a virtual reality, this reaction is defined by a pseudo-physics that governs what happens when this interaction occurs.

When you’re working with phantom objects on SL, or regular objects that are not explicitly physical, you can’t rely on the built-in physics system, and thus you must design your own–from the perspective of parsimonious code being the most efficient (read: best), this is basically a “good-enough” physics system that will emulate just the wanted or needed reaction.

If you’re trying to program virtual critters (VC) or moving objects that are phantom, you’d need to worry about what happens visually when they collide. They ought to be “smart enough” to bounce away, or try avoiding merging into each other. A simple solution would be to have a llSensorRepeat() detect and react to objects that enter a certain small “bounding sphere,” whenever the virtual critter (VC) is moving. Upon entering the radius of this bounding sphere, the original VC will try “hopping” a random-small-distance away from the impending VC. Similarly, since the impending VC has the same bounding sphere “pseudo-physics”, it will try doing the same thing. Both VC’s will continue hopping randomly away until their “bounding spheres” do not intersect. This is the HB Bunny 1.x solution to avoiding the classic “merging phenomenon” demonstrated in the beta.

Characteristic behavior is really an orchestra of interaction, a sequence of action-reaction occurrences–a sunflower blooming towards the sunlight, a mouse attracted to cheese. But yet, when you look in nature, on the subject of group animal movement, you wonder what keeps them together in the way they move. For example, migrating birds often fly in a V-shaped “formation”. Obviously, the solidness of their physical bodies keeps their bodies from merging, unlike the phantom VC’s described earlier, but how do they know to fly in this V-shape, and why do they do this? While science has speculated on several reasons why, deferring to economy of such motion, how they do it requires both wirings in the bird brain that respond to such a situation, as well as features in reality that allow this. When cast in such an abstractified perspective, it becomes clear that what’s happening is that there is simply a different, but “equivalent” mechanism at work to keep things in formation–in reality, and in its emulation, virtual reality.

A series of such mechanisms might be considered to be governing characteristics of a paradigm. In the case of the phantom VC’s, their movement might be set such that they will move only when they detect a mat, and such that they will stay level only to the mat. Because the VC will detect the mat, it is almost like a magnet, or from a more macroscopic perspective, the mat is like a flat earth — although, contrary to what the Flat Earth Society believes, the mat doesn’t accelerate(!), and yet things simply stick to it.

A pseudo-physics that deals with only the known elements in a microcosm works because the VC only has to react to certain things, rather than to all elements in the physics of its containing world; moreover, having the VC respond only to such known elements in a microcosm is more resource efficient. Using this idea, in a pseudo-physics named “FIZ”, the HB Bunny implementation of my VC design averages to only 0.1 ms at peak, which is a fraction of what most AO’s take. The HB Bunny will “hop” away when they hit each other, or small objects named HB Rock. They detect only objects known to them, such as HB Food (which they eat), HB Toy (which keeps them happy), and HB Mat (which, they stick to). Moreover, in SL, when one uses VC’s whose prims are sculpted prims, it is actually necessary to use an alternative physics system, as sculpted prim bounding-boxes are not always as expected and precise as those of regular-prim VC’s. The phenomenon that may bring wonder is that with such simple behavior constraints, a VC that appears “alive”. And, with further internal constraints that will change their behavior, such as growth functions and mating functions, VC’s appear “living”–more on that in a later section, though!

The idea of having a creature react only to things that are immediately relevant to it, or that it is capable of detecting, is actually a common phenomenon in nature, RL. Humans and other animals live in the real physical world, but are capable of perceiving only a limited subset of reality. For example, we humble humans are not capable of seeing UV or infrared light, though other animals can; we are consciously susceptible only to a limited subset of the electromagnetic spectrum, though our bodies may react incrementally to gamma-ray bombardment, for example, its effects are 99.9% too small for any macroscopically-observable difference to occur. Many examples also exist on the size spectrum; we can’t see things that are too small (a virus, for example), or too big (the universe! - we live in it, but we can’t detect its entirety). But yet, we function in our own paradigm, and equivalently, so do these VC’s.

III. The Protocols of Life… Er… aLife!

Artificial life or, to coin a term, “aLife” might be considered a fine-tuned simplified set of protocols that emulate life, with complexity depending on the realism of the particular aLife entity. There are three general categories of aLife protocols–external interaction, internal determination, and non-interactive autonomous behavior. I will briefly discuss elements of each category for VC’s, particularly in relation to their implementation in HB Bunny.

External interactions occur when either collision occurs, or when an interaction is proximate, within detection vicinity.

Collisions occur with either the environment or its objects. In a pseudo-physics as described above, i.e., a physics that deals with only a limited microcosm, collisions that generate recognizable reactions would occur only with known objects, such as objects named a particular name, or flagged otherwise for detection. In the HB Mat example above, the HB Bunny’s environment is simply its mat, and this is its entire world, on which it can move. (However, if the mat is moved slowly, the HB Bunny will be able to go beyond its old bounding box environment, to “move with the world;” but, it is really the world that moves the VC…)

Some examples of possible proximity behavior phenomena are sickness (too many VC’s nearby), friendly interaction (gathering to sleep at night), or mating (for sexual creatures, at least two’s required). For HB Bunny, sickness occurs when the VC detects more than 6 scripted objects named HB Bunny nearby; sickness is manifest as an incremental counter, from 1 to 100 units, which can be decremented when the VC is hungry, and eats twice as much to decrement both hunger and sickness. HB Bunny will first find each other, in friendly “compassionate” behavior, and gather close-ly at night time to sleep, before deactivating all detection until daytime. Mating is possible when a HB Bunny is more than 14 days old, and is fully-grown and considered an “adult bunny”; presence of an eligible non-pregnant mate of the opposite gender is required.

Mating is perhaps one of the most important components, when you’re creating aLife for the purposes of viral breeding. And, since we’re 21st-century non-gender-discriminating folks, a significant mating system for VC’s must account for the case of gayness or genetically-disposed celibacy (with respect to impregnating). From the perspective of statistics, gayness might be considered a non-systematic deviation from the mean. Thus, consider a system where gender is assigned on birth of a VC as a global variable, and where this global variable might–in an extremely rare case–be reset. Assign the null value of gender to default to female VC, and the non-null value to be the male VC; when reset, or when communication error occurs (which has a higher chance on noisy-platforms such as LSL/SL), gender becomes “miscarried,” and you wind up with an effectively gay VC (i.e., outwardsly-male, inwardsly-female).

But, in general, the proposed VC mating system does contain the regular features of mating, such as VC-preferred-selectivism in mate selection, as well as birthing processes. This is best summarized in the diagram here (please click to see the larger version):

virtual critters mating protocol

Mating selection occurs on closest-match of a random number generated by the female and male bunny; call this the mating random number (”MRN”). To add “personality-in-female-choice,” in the HB project, I chose to have the male bunny generate his MRN at birth. A female bunny generates her MRN each time she goes into heat. The male is the one who chooses which female number is closest to his, and thus will favor a certain female if she generates the right MRN each time they meet while she is not pregnant (they’re bunnies, and not monoagamous).

To conserve resources, heat only occurs when there are eligible opposite-gender adult bunnies nearby. For HB Bunny, mating only occurs when bunnies are near non-pregnant entities of the opposite sex, and if bunny characteristic conditions fit (bunny has to be both happy and energetic enough).

Internal Determination is necessary to show changes in a VC’s characteristics (such as its core stats - happiness, energy, hunger, sickness, etc.) and changes in states. A VC contains a –literally — biological clock that governs its self-behaviors, such as growth and perkiness. A VC has three general states: awake/living, dead, and sleeping (semi-conscious). In the case of HB Bunny, when it is sleeping (and has found the other bunnies, if any), the entire script “goes to sleep”, suspending detection of other objects, effectively giving the simulator hosting the VC, some time to cool off. When the VC is living, it goes through its full range of behaviors. When the VC is dead, it simply ceases to exist in the virtual reality, other than as data stored in a database somewhere.

Non-Interactive Involuntary-Autonomous Behavior is generally an aesthetic feature of VC’s, as they do not have any “internal organs,” other than scripts. HB Bunny VC’s blink and twitch, and sometimes, they “bristle” on SL texture change lag.

IV. Concluding Remarks - Some Thoughts on Copy Protection and “Playing God”

The rage about SL virtual animals is likely due to the spirit of creation, albeit in a VC-promiscuous way, but then again, it’s also due to the value that they (and their offspring) develop, in part due to their rarity. Copy-protection is essential to the survival of a VC line whose lifespan depends on costly server-resources to run, which is, paradoxically, funded through steady sales of VC’s. But, next-generation propagation is also important, so I will discuss the general idea behind the propagation of turtles and Sion chickens (call this the “traditional method”), as well as alternatives.

validating virtual critters for transfer or spawn

The “traditional method” for a VC to give “birth” to offsprings essentially has the female VC rez an egg, and then have her drop a VC in the egg. The mother has a copy of this offspring VC in her inventory; her offspring in the egg, does not (but will, once they are born, as the egg script, will, in turn, give a copy of the VC to the newborn - though, for HB, this happens only for the female newborns).

This idea of a script creating a copy of itself sounds like a worm or a virus, and in fact, the adjective “viral” totally works. This concept is best illustrated through an interactive example. Drop by the park-like area next to the Skin City Library (NorthEast side of Skin City sim) to grab a copy of an “Infinitely Viral Urn.”

The “Infinitely Viral Urn” is the most basic implementation, with delayed inventory-drop check, of a script-based object self-reproduction. You only need to get a single urn, touch it, and it will give you another urn, that will, in turn, be able to “give birth” to yet another urn, and so on. What’s interesting to note is that if you attempt a “Cesarian,” by just taking the baby urn from the mother urn’s inventory without having it being “born” through a regular touch-rez, the baby urn will poof in a quick burst of stillborn particles. This is basic copy protection, where rezzing of a scripted object is only permitted by the script.

On SL, though, the problem of no-copy becomes complicated with a faulty permission system. The “traditional method” for copy-protection is also what’s done for the classic SL-AI-esque VC’s, the turtles and chickens. When a VC is transferred, it must be taken to inventory or sold in-place; using the SL feature of take-copy will disrupt normal script-flow and disable the VC. When taken to inventory, the traditional method requires that the VC be boxed. While the VC may be a +copy/+xfer object, the box itself is always no-copy. One the VC is boxed, it’s the box that is the inworld indicator of the uniqueness of the original VC. To prevent both the old owner and new owner from having the same copy of the VC, the box applies its no-copy permission to its inventory VC. When the VC is unboxed, what occurs is that a completely new VC is rezzed, but the data that defines the characteristics of the old VC is transferred, to give the appearance of the old VC’s continual existence, even though it technically ceased to exist the moment it was boxed.

Incidentally, a seamless updater works just like unboxing a VC, except the new updated VC is rezzed in the position of the old VC; it’s the same idea of “injecting” data from the old VC into the new, to make it appear a continuous incarnation of the original. Like boxing, the original was destroyed upon updating.

An alternative way to facilitating copy-protection would be to use a technique I’ve dubbed “pregnancy fortified food“. This would allow the best of protection in that all VC’s would have the SL no-copy permission, because the new VC is actually the no-copy inventory in the food bowl. (Kind of brings a whole new perspective to “eating something to get pregnant!”)

virtual critters reproduction and feeding tokens

In conclusion, I can’t help but recount the times when I felt like some deity when planning the general VC diagrams, and in implementing the HB Bunny, and in fact, it was more hubris than anything else that prompted me to take this project. I was even high enough to address myself as “Bunny Goddess”, at one point.

In beta phases, we tested the HB Bunnies on shortened lifespans, roughly 1 beta day = 10 regular days. (This meant the bunnies became adult and mating-age in about 1.5 days.) So, anyway, the fact that 1) these bunnies will automatically sleep at sunset, 2) have predetermined “promised lifetime of 356 days (barring starvation or sicknes)”, and 3) essentially have their body mechanisms limited by AI, and more, does not make me like the Goa’uld experimenting on the Argosians. (If you read this entry before hulu takes it off, the entire Stargate episode where that happened is embedded below.)

I confess. I’m just Ina. Ina Centaur ;-)

Category: Amusing, Daily Sumly, Projects, Reflections, Tutorials, bots


Written by ina on Saturday, 19 of January , 2008 at 10:12 am
Tags: , , , ,

iVizClone logo (Here is an early draft of the infoCard for my VizClone exhibit at the tech.)

VizClone is a visual artificial intelligence experiment where a robot uses fuzzy logic to “focus” on an individual in the crowd and clone their image in real time 3D. Robot sees. Robot becomes. You shall see!

The Second Life implementation uses libsecondlife to scan avatars in the vicinity, a fuzzy logic algorithm to choose an avatar to focus on, and libsecondlife to grab their baked textures onto the “robot”.

The Real Life implementation may occur with either an array of cameras capturing the nearby people, and then a multimedia projector projecting on a blank 3d statue, or perhaps a hologram to create the clone.

Category: Projects, bots

Who is Ina Centaur?

A 25-year old American polymath of Taiwanese ancestry pretending to be old and Caucasian in Second Life. Semi-retired independent scholar also dabbling as an independent artist in new media, particularly theatre and the humanities—notably Shakespeare. Programmer, playwright and novelist. Formal academic background in, philosophy, and bioengineering.

This is largely a personal blog which isn't always up-to-date. There's no one definitive way to stalk me ;-).