Creature Sim : Gene suppression idea

July 22nd, 2008

Some Ideas for further development of the simulator:

Suppressed Genes

It may be interesting to add the ability to suppress genes in the genome.  This type of feature would introduce recessive traits that can be retained in a creatures Genome and passed down, but de-activated.  Although the gene wouldn’t be lost, it could have a chance of being re-activated in later generations.  A SuppressingGene class could be used.  For example, to suppress a joint, a gene is added that is derived from GeneJoint.  The derived Gene will have a modified render function. 

This capability would require the ability to change GeneTypes on the fly.  A ruleset on how this can happen needs to be defined.  Perhaps a Compatibility calculation can be done.  I am not sure how this would work…

One method may be to keep the structure of genes the same.  For example, keep all variables after the constructor/destructor.  Doing a sizeof() analysis of two genes will indicate if they are compatible.

This is what it may look like:

class gene1
{
   gene1();
   int d;
   std::string var;
}

class gene2
{
    gene2();
    vector<int> v;
    int d;
}

class gene3
{
    gene3();
    unsigned int z;
    std::string dvar;
}

For these genes, only genes 1 and 3 are compatible.  When reproducing, there can be a small chance that the gene can flip between gene1 and gene3.  The reasoning would be that because the data in the genes is so similar, they probably serve a similar structure.  This of course will not always be the case, and that’s why not all mutations will be beneficial.

Creature Sim update : Structure

July 18th, 2008

Working on the CreatureSim program, the structure of a creature is beginning to become more complicated.  I am going to map out the objects that make up the program to keep their relationships clear.

The program structure (Location of Objects)

Main
 +-CEngine
     +-Creature
          +-Genes
 +-CRenderer

Objects

Gene
 +-GeneBody
 +-GeneAge
 +-GeneLimb
 +-GeneJoint
 +-GeneMotion

The structure of a Creature

The creature looks like the following

Creature
 +-Gene* Genes
 +- x location
 +- y location

The entire description of how the creature behaves is contained in an array of genes.  Each gene has an inherited render function that controls how the behaviour or image of the gene is rendered.

An Example Creature:

Creature
 +- x = 10
 +- y = 10
 +-GeneBody
     +- radius = 10
     +- points = 8
 +-GeneAge
     +- Age = 20
     +- OldAge = 400
 +- GeneJoint(1)
     +- AttachTo(GeneBody, angle)
     +- AttachTo(GeneLimb1, angle)
     +- Motion[GeneBody] = 0
     +- Motion[GeneLimb1] = GeneMotion
 +- GeneLimb(1)
     +- LeftAttach = GeneJoint(1)
     +- RightAttach = GeneJoint(2)
     +- Length = 5
 +- GeneJoint(2)
     +- AttachTo(GeneLimb1, angle)
     +- AttachTo(GeneLimb2, angle)
     +- Motion[GeneLimb1] = GeneMotion
     +- Motion[GeneLimb2] = GeneMotion
 +- GeneLimb(2)
     +- LeftAttach = GeneJoint(2)
     +- Length = 2

This creature would be an octagon with a tail attached that has a pivot point in the middle.

Additional genes can be added dynamically and development of new capabilities will not require coding and additional work on existing genes.  The functionality comes from iterating through all genes in the creature.

Next Task:

  Asexual and Sexual reproduction: How do the genes and DNA of two different creatures mix?

Creature Sim Update : A start

July 5th, 2008

To start, I have created every creature as a circular polygon with x points.  The number of points is a gene that can mutate.  There are randomly generated limbs, in number and size that attach to the body. 

At the moment, the movement engine only calculates brownian motion.  That is, small random pertubations in the position of the body.  Added to this motion in the future will be motion derived from moving limbs and from being pushed or pulled.

The next step is to add capability for the creatures to have moving limbs.

Ideas:  Each limb can have two joints (one on each end).  Each joint can have up to 10? limbs.  The original generation will be random, and evolution will take place from mutations and reproduction.

Possible algorithm for limb combination:

Creature 1:

Limb 1, length 10

Limb 2, length 4

Creature 2

Limb 1, length 12

Offspring

To calculate # of limbs:

  1. Offspring will have 50/50 chance of 1 or 2 limbs. (Let’s say we got 2)
    1. Offspring limb 1: Length 10 to 12 + rand(2) - 1
    2. Offspring limb 2: Length 4 to 12 + rand(8) - 4
  2. Let’s say we got 1
    1. 50 / 50 chance of mixing with Creature 1 limb 1 or 2 
    2. Offspring limb 1: Length 10 to 10 + rand(2) -1

 This is just a general idea of how the limb-mixing algorithm might work.

Joint motion ideas:

The joints will move as a sum of sine waves

The motion will be a function \theta (t).  The amplitude of the function will be limited from -180 to +180 degrees.  The function will be a sum of x sine waves.

for example

\theta(t) = A_1 sin(\omega_1 \cdot t + \phi_1) + A_2 sin(\omega_2 \cdot t + \phi_2) + A_3 sin(\omega_3 \cdot t + \phi_3) such that A_1 + A_2 + A_3 is less than 180

To genetically mix the motion genes, of course the variables will be randomly combined and normalized so that the offspring will move similar to how the parents did.

That’s all for now.

Diamagnetism

July 3rd, 2008

With my personal research, I will be collecting and compiling notes on diamagnetism.  I am interested in going further than just a verbal description of the effect, and will pursue a more fundamental understanding of the topic.  I will continue to edit this post as my notes continue to grow. 

This post has become kind-of long, so I have started to divide it into multiple pages.  Here is a summary table of contents:

  1. A list of points about diamagnatism
  2. Equations that will be used in calculations
  3. Some problems to calculate
  4. Calculating physical properties in systems involving diamagnetic materials
  5. Physical properties of some diamagnetic materials
  6. Sources and distributors of materials for experimentation

I hope to let this post grow and maybe one day it can become a good reference on diamagnetism.

Read the rest of this entry »

Diamagnetic Levitation

July 1st, 2008

Background is available at wikipedia: http://en.wikipedia.org/wiki/Diamagnetism

Earnshaw’s Theorem:  The hopes for magnetic levitation look dim after studying earnshaw’s theorem.  The idea that magnets interact with each other through forces is tantalizing and one assumes that an arrangement may exist in which magnets can support other magnets in levitation.  Earnshaw’s theorem almost dismisses that concept.  The potentials for interaction lead to unstable equilibriums.  The saving grace is that the diamagnetic effect added to the interaction can make a potential with a stable equilibrium.

Some diamagnetic levitation experiments:

The Meissner effect:  Superconductors are a perfect diamagnetic.  There is more than one way to analyse the situation of a magnet near a superconductor, and this is one way.  Any magnetic fields impinging on the superconductor will induce eddy currents, which induce a magnetic field that will create a force opposing the impinging field.  A N pole facing a superconductor will induce a N pole in the superconductor, creating a repulsion.

Zero Energy Input diamagnetic levitation: For a material such as Highly Oriented Pyrolytic Graphite (HOPG), which is a strong diamagnetic material, the force generated when interacting with a magnet is sufficient to levitate the graphite.  A small kit illustrating this effect can be found at scitoys.

Diamagnetically stabilized levitation: The levitation work is done through the interaction of permanent magnets, and the diamagnetic force augments the interaction potential to create a stable equilibrium.  There are a few configurations with which levitation can be stabilized.  One is with two permanant magnets attracted to each other, with a diamagnetic in-between and gravity pulling down.  Another is with an electromagnet lifting a permanent magnet, and a diamagnetic material used to stabalize the lifted magnet horizontally.

(I’ll try to find some pictures of all these effects)

Creature / Evolution Simulation

June 20th, 2008

So I started writing a program with a neat concept in mind.

I got some ideas from a few interesting articles that I’ve read:

The evolution of Clocks youtube video, in which someone wrote a program that selected traits from clock parts to make a timepiece.  Also, this JAVA simulation with moving creatures that lay eggs and pass on their genes to survive. 

I wanted to go further.  I started a C++ program with a few ideas in mind.

The creatures will live in 2D and interact with an environment that a user can control.

 The base class will be a creature.  Each Creature will have an array (vector) of genes.  Each gene will be of a certain type.  The base class will have some fundamental functions such as how to render that trait.  Also, genes will interact with each other, and even generate each other.

an example of a gene would be a GeneLimb().  This gene will be a base class gene and will render as a stick.  Another gene called GeneLimbFlesh() will link to GeneLimb() and render a shape (oval) over GeneLimb() There can be more than one GeneLimbFlesh() for each GeneLimb().  There will be many GeneLimb()’s for each creature.  Each GeneLimb() can attach to either the base or to another limb.  There will be a class called GeneLimbColor() which controls what the limb’s color is.  GeneLimbJoint() will be a type of limb that supports motion.

A physics engine will interpret motions generated by GeneLimbJoint() to create a force.  this force and type of motion will enable the creature to move.  More successful limb arrangements, allowing for more motion (and ability to get food/reproduce) will help support survival.

Other Genes will control:

  • Position of mouth
  • Size of mouth (Can it eat a smaller creature)
  • Position of eyes
  • Accuracy of eyes
  • Position of sensory organs
  • sensory organ capability
  • Color preception
  • digestive capabilities. (For different types of food)
  • Joint “Waveforms”
  • skeletal protection
  • aggressivness (Probability creature will avoid others)
  • Poison capability
  • Thermal properties (Fuzz?)
  • Male / Female / Other

 There will be a reproduction algorithm in which the genes from 2 or more creatures will intermix if they mate and the offspring will be a unique creature with traits of the parents. 

 Changing the environment will have interesting effects on the evolution of multiple species in the simulation.

Most recent status:

I have written the basic framework using the irrlicht graphics engine.

New Computer!

April 17th, 2008

Me and Colleen now have our new computer.  Our old one died a rather unremarkable death.  My good friend Nathan, back in Lethbridge works in the computer industry.  So naturally, I got his help getting a new computer.  Here is our new setup:

Intel Core2 Quad Q6600
4GB RAM
NVIDIA 8800 GT
37″ Sharp Aquos 1920×1080 display
1.3 Tb Hard drive space
Vista Home Premium
Wireless Logitec Keyboard
Logitec Wireless Laser Mouse

It’s not the best set-up out there, but we decided we wanted something we felt would last a few years and be within our price range.  Playing Lord of the Rings Online with our new system is even better now.  That’s a game me and Colleen enjoy together. 

I can say for sure, I am very hapopy with our new system.

I’m still alive

April 17th, 2008

Yes, there’s a large gap in posts.  That’s because I’ve been a little bit busy to write lately.  I recently received my domain renewal invoice, and decided to keep running for another year at least.  Hopefully I’ll have a few posts that may be of interest to someone.  I’m thinking of using this blog as more of a journal of mine, and maybe that’s all it will ever be. 

Keep your eye on this space…

Canada’s Radioactive Isotopes

December 13th, 2007

So here is a story i’ve been reading about.  If anyone (like I ofen do) skims headlines and subjects, may not really get what’s going on.  First of all..  this is what is reported:

  • Reactor taken offline for safety reasons
  • Lack of isotopes for medical use
  • Government forces reactor to come online despite safty issues

Sounds bad doesn’t it?  Well, this is my interpretation.

 From the globe and mail:

“AECL assured the CNSC last year that an emergency power system had been connected to the cooling pumps on the 50-year-old unit. But the CNSC discovered last month that the required installation had not been completed and took the reactor out of service.”

So, this is the actual case:

  • Old reactor has been running fine for many years

  • Emergency power wiring was to be installed on back-up pumps (i.e. a safty on a safety)

  • Since everything was looking good, nobody noticed that the work was never completed

  • Inspectors discover this, deem the plant unsafe and shut it down.

  • Lots of engineering and planning work need to take place to install the upgrades and safety’s.  Meanwhile, no supply of isotopes.  This can take a while.

  • Government mandates that since the reactor was working fine before, why not let it continue running.  A good idea in my opinion.

  • The reactor re-activated, while the plans are drawn up for the upgrades.

  • The plant will be taken offline for a short time at a future date to make the upgrades

Result:  The world can still diagnose medical problems while the folks in charge of the reactor fix their goof.

Looks good to me.

My latest project(s)

December 7th, 2007

I always like to dabble into various different projects.  Here is what I’ve got going on at the moment:

  • Building a folding-leaf table.
  • A magnetic interaction simulator (with real physical results)
  • Galactica.Sim clone (Great game, but it would be wonderful if it wasn’t 1 hour turn based.)

Those are the major ones that I’ve been devoting time to during the last few months.  I don’t expect many breakthroughs, but maybe.