Log 19/04/2012

Regulating temperature

In real life reptiles are cold-blooded, this means that they cannot regulate their own body temperature. Reptiles bask in the sun to keep themselves warm and this is a behaviour that the virtual reptiles in ReptileX will exhibit.

In order to implement this the environment in ReptileX needed to have different temperatures, a nice way to represent this would be to have different coloured sections of the ground which were different temperatures, these colours would relate to the temperature i.e. red for hot and blue for cold. Initially it was decided that the simplest way to represent this would be using a grid so different squares would be different temperatures. In order to do this a function was made which draws a rectangle from the corner in the x and  z direction when given a x and z position and a width and depth. This is very similar to the ofRect an rect (in processing) functions which draws a rectangle from the corner in the x and y directions when given a width, height and x and y positions.

Once the grid had actually been implemented using though it was found that it would be to complicated to find out wich square the reptile was on and which colour it was as the grid was drawn using nested for loops and time was getting short for getting into complex problems. The grid also looked very basic, a much simpler and nicer looking solution was to still draw one large plane using the plane function and use OpenGL’s special feature which blends colours between vertices making the plane red at zero z and gradually blend to blue as it moved in the minus z direction. This meant that the reptiles could just find out their temperature based on their z position.

So in the environment function a was written which returned a temperature between zero and one hundred, this could be called from within the reptile class and given one argument, the reptile calling its z position. So now depending in where in the environment a reptile is it can will be given a different value for temperature, once properly calibrated this related directly to the colour of the plane so the redder it was the hotter it was and the bluer it was the colder it was.

Next the reptiles were given a body temperature and this was made to change at all times subject to the temperature their current position in the environment. Then a function was made which made this affect the reptiles, firstly a boolean called cold was switched on if the temperature went below a certain amount and secondly the reptiles speeds and speed and health was decreased if they were to cold. But initially this stopped them moving so it was taken out and left to troubleshoot later.


Next the reptiles needed to mate, up until now only the plants have been able to breed and they have done this asexually, as a simplification of nature. The reptiles on the other hand needed to mate sexually, mixing their genes. The reptiles were all given a gender randomly wether they were in the start population or not. Firstly only two reptiles were created and the nearest neighbour algorithm was tailored to search for females, making sure to store the pointer to the node that holds them as well as their position, this function was only to be called by male reptiles. Once the nearest female had been located her position was used to calculate her direction so as to move towards her. The male then uses a specially tailored version of the collision detection algorithm which checks only for collision with the female its heading for.

A function was written which could be called by the male reptile once the female was hit using the pointer to the her node in the linked list which was stored when she was located. This function was called inseminate and it takes a pointer to males gene as a parameter and switches a boolean called pregnant to true. So once the male has called this function in the female she holds the adress of his gene.

Mixing and mutating genes

Now the genes just had to be mutated and mixed then a new ‘baby’ reptile needed to be created which would inherit the new gene. So the female was given a function called mix genes which is called by her inseminate function, this first mutates both the females own gene and the males gene before they are mixed, the mutate function the plants used was improved and used for the reptile this randomly picks a few random places in the genome vector and changes the value there by a random number. The two mutated genes are mixed by stepping through the chromosones and randomly picking the attribute from the male or the female to put in a new chromosome vector for the baby. Once this has happened the female holds a new gene for the baby and pregnant is true. In the code for the reptile node each time the runtime functions are called each node checks if the reptile it is holding is pregnant. If it is then a function is called that makes a new reptile using the and gives it the new gene.

Meeting with supervisor

Had a meeting with the supervisor and it was decided that a complete project report and a working version of the program should be handed in on the 25th of April so as to get some feedback. This interim deadline would give a week and a half for any improvements.


About evolvegold

I am a third year student doing Creative computing at Goldsmiths college University of London. View all posts by evolvegold

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: