Worklog for Drak

Botz!

Return to Worklogs

Link(Posted 2010-01-17)
Never posted a link in my worklog:
Botz 1.0, 630kb, no media needed
http://www.mediafire.com/?ojzmgjndgmn


Clarification(Posted 2010-01-10)
I forgot to mention that all food nodes are diamond shaped, while bot shelters are not. This subtle difference makes identifying each at a glance easy.


A couple of screens(Posted 2010-01-09)
This is a screenshot of the simulation after it has run for about 30 minutes. Lots and lots of bots on the screen, also lots of food.

Green diamonds are plants, red are carcasses. Bots are the other colored spheres. Colored boxes are that particular color of bot's houses. In this picture you'll notice the white\very light blue bots are dominant in this area at the moment.




Here is a screenshot zoomed in a bit further. You'll notice the bot (sphere) with a green halo around it. That's the bot I currently have selected, (kind of middle of the picture, and a bit to the right) and it's stats are printed out in the upper left hand corner. The large red bot in the upper middle of the screen is a Carnibot (carniverous bot) who feeds on other bots.

This level of zoom you can see which direction each is headed. Notice how each bot's shelter (the boxes) do not overlap each other. This took a long time to get right codewise, but is working beautifully. (Read below worklogs for further explantions)




A while later:

There is a carnibot in this picture near the middle upper portion of the screen again. Notice how every bot in close proximity is fleeing for it's life? Thats why I like this picture. You'll also notice that purple has pretty much dominated this whole particular area.



This is a GREAT photo below.

Look at the pink bot with the green circle around it. It's strain at the top left part of the screen reads 7.26M.33M. What does this mean? Well, strain 7 is the purple bots that domiate this area. A purple bot (from strain 7) mutated into a NEW strain called 7.26M. I actually refer to it as strain 26, and the 7 just refers to the fact it mutated from strain 7. This new strain did well, and one of THOSE bots mutated into a new strain AGAIN called 7.26M.33M. (or 33 if you will) It's real easy to see which ancestors each new strain had. (Read below for further explanations of strains and mutations)




Initial worklog(Posted 2010-01-08)
I've been keeping a worklog in a text file, and I am nearing completion, so I'm going to start posting here.

Group A:
seeks food, eats both plants and meat
seeks shelter (can construct)
dislikes other colors (strains) of group A
may carry diseases


Group B
seeks food, carniverous
eats group A
does not need shelter
resistant to diseases


Group A will build a shelter while not busy eating. It's goal is to obtain shelter so it
can reproduce itself. A group A bot cannot reproduce without shelter.

-------------------
12/7/09 ;FOOD VALUE
Botz will now go to a food source based not only on it's distance, but it's nutritional value as well.
The simplified formula is (n-d/2). n is nutritional value, d is distance. Close, nutritional food
will have a very high "food value" while further away nodes will have a low or negative value.

Each bot will "know" which food source will give it the best nutrition, but will have to pass
an intelligence check or it will simply eat from the closest node. Very close nodes should always
be the best food value, unless they are extremely low in nutritional value.

;------------------
GET FOOD INTELLIGENCE CHECK
***This is no longer how food is selected!*** ***Read below***
Very uneducated bots should now die fairly quickly because they will not realize they need to eat before
they starve.
This is intended to quickly weed out inferior botz.

;------------------
12/11/09
FOOD REGROWTH AND DEATH
Food nutritional value is maxed out at it's creation. Example, a food with a value of 28 cannot
regrow to more than 28 nutritional value at this time. A food source that has been eaten from
will have it's nutritional value decreased by 1 each time it is eaten from, although it will begin to
regrow instantly, but never more than it's original value.

A food source that is eaten to less than 1 nutritional value is of little importance, and would
be mostly destroyed. It is considered to have died if this value is less than 1. It is then deleted
and recycled back into the planet.

;------------------
;12/12/09
;SHELTER
Every bot will now construct a shelter after finding food for the first time. They will create
it in a random location close to it's current favorite foodsource. If the bot switches foodsources
and it's home is further than it would like to be, it will move it's shelter closer to it's new
food source.

;AGING
I've implemented aging into the simulation. Each bot keeps a running total of each iteration since
it's birth. When this number reaches and exceeds it's max age, the bot will begin to lose health.
When the bot reaches 0 health it dies of old age. Max age is currently a combination of all 3
of the bot's stats. (Intelligence*strength*constitution) The maximum this number can reach is
one million. (100*100*100) The lowest it could possible be is 1. (1*1*1)

;COLORS
There are 15 bots spawned at the beginning of each simulation. I've given each one a random color
when the program is exocuted. This way it's possible to tell which bot's strain is reproduced when
the bot reproduces itself. It's actually pretty neat because eventually when the genetically poor
die out and the genetically rich reproduce, it leaves just a few colors of bots.

:REPRODUCTION
Each time a bot returns to it's home, it has a 5% chance of reproducing itself, regardless of genetics.
The only thing genetics has to do with reproduction is that genetics will determine how many times
the bot returns to it's shelter, how fast it gets there, and how much food is burned getting there.

;-----------------
;12/14/09
;DEATH AND ITS FOOD INFLUENCE
When a bot dies, two things can happen. If a bot dies of old age, it is transformed into a food
source with nutrients equal to the bot's current hunger value. If a bot dies of starvation, it turns into
a food source with a random value. I may delete this because if you think about it, if a rabbit
were to starve to death, it wouldn't satisfy the hunger of a hungry wolf. Just an example.

;USER INPUT
There are 2 things I want to accomplish in the way of user interaction. First, I want to give the user
the ability to delete botz. Why? There may be a need to remove or declutter a particular area of the
"world". Second, I want to give the user the ability to add food sources. Why? Because the "world"
is never perfectly balanced, and at some point, the botz will outgrow their food sources. This is almost
a guarantee.

Ok, that's done. To delete a bot permanently, first select it by clicking on it with the LMB. Then,
push the delete key and the bot will mysteriously disappear.

To force the bot to move it's house, select the bot again, and must the h key. This demolishes the
current shelter and picks a new location for it. This is useful when 2 bots have an overlapping shelter,
as one may not be able to fully enter it's house. Moving it will fix this. ***Note: 1/2/10 Bots will now delete their
own house if they can't get to it in a fair amount of time. ***

A food source can also be deleted the same way as a bot can.

Pushing the p key will place a randomly placed plant.
;-----------------
;1/1/10
CHANGES
When a bot dies of old age, the food source it leaves is now classified as a carcass instead of a leafy plant.
It is also colored red to distinguish it from the rest.

I also changed the value of the food a starved bot leaves to 5. This is to represent the little
amount of nourishable food left on the botz' body. Carcasses all have negative food regrowth, unlike plants.
A carcass will be deleted from the world as well when it's nutritional value is lower than 1.

;-----------------
;1/2/10
;CAMERA
I had a situation today as I was letting the simulation run. I was away from the computer and the mouse was
stuck moving the camera in a direction I was unaware of, and could not find the botz again! So, now, pushing
the C button will reset the camera to the default position, in case this happens again.

:NEW PLANTS
A new plant will now be created at random moments. This, so far, allows the simulation
to run indefinately as long as at least 1 bot is alive.

;MUTATION OF BOTS
Bots currently have now a .2% chance to mutate into a whole new strain (species) each time they return to their
shelter. The new strain will mutate quite a bit from it's parent, with some traits varrying by as much as
25%. However, some traits do not change much at all. The new strain is given a NEW color and also a new name.
Lets say the new bot is created from a strain number 8. It's new strain will now be something like 8.17M. The 8
signifies it mutated from the number 8 strain, and the 17M is it current new strain number, followed by the M
to signify it as a mutated version. Mutated versions are simply new strains of botz and follow the same rules
as the original 15 strains. If a mutated strain further mutates, it will tack on another set of numbers to it's
name, such as 8.17M.29M. This means that bot mutated from a strain 17 mutation (M), which was mutated from
a number 8 strain, and is now given the number 29(M) as it's own designation. Keep in mind there could be
also numbers such as 8.17M.25M., and 8.17M.22M. However unlikely, this means that the strain 8.17M mutated wildly
TWICE into 2 new strains of 25 and also 22! Confused? It's really quite simple. In one test I ran I got up to
numbers like 8.17M.26M.33M.46M.58M!

;SHELTER RELOCATION
If a bot cannot reach it's shelter in time after eating, it will tear down it's house and relocate. Why? Because
sometimes another bot will block it's path to it's home, and cannot get to it's shelter. The bot is reset to status 0
when this happens. Status 0 is idle. ***THIS HAS ALSO CHANGED, SEE 1/8/10.***

;-----------------
;GET FOOD INTELLIGENCE CHECK
I modified the check to see if a bot will get the best food, or the closest food. I made it simpler. The way it works
is when a bot decides it needs to eat. (Which IS based on it's intelligence), i roll a random number from 1 to 100. If
the number rolled is higher than the bots intelligence, it fails and will eat from the closest food. If it passes, it
will eat from the BEST food source. Of course, this could also be the closest, depending on the situation.

:PAUSE AT EATING
I also noticed I had commented out a delay while the bot is actually eating, meaning they were eating instantly. The
pause is not long, just a few seconds while the bot grabs some food.

:SUNLIGHT INTRODUCED
Sunlight is now a variable factor. 100% sunlight for this simulation is considered to be an optimal amount of sunlight for
the plants that botz eat. Higher levels of sunlight (power) will increase plant regrowth, while numbers lower than 100
will reduce it. At 0% there is no regrowth. Most bots will be dead by then anyway because sunlight also impacts another
factor I implemented.... temperature!!!! If sunlight levels get out of hand, they can have drastic effects on the planet.
Both bots and plants can be affected by temperature.

;-------------------
;1/5/10
;CHANGES TO GET FOOD
I decided to change when a bot needs to get food today. Even the dumbest animal in the world knows when it's time to eat.
So, instead of using intelligence as a base of when to eat, I'm using the bots individual metablolism. Multiplied
by a certain amount. If hunger falls below this amount, it'll go and eat.

However, there is still an intelligence check to see whether the bot eats simply the closest, or from the best food
source.

;COLLISIONS AND AVOIDANCE
When a bot runs into another bot, they will ALWAYS turn right. This way if 2 bots meet head on they won't be stuck turning
at the same increment. It looks good and works pretty well too. I cannot have bots turn in random directions because if one
turns right and the other left, if they met head on, they would be stuck still.

When a bot runs into 2 other things simultaneously, the bot will back up while turning either left or right. This is
intended to reduce traffic jams around high traffic/high population food nodes. It works pretty well, too. So you may
notice bots backing up every now and then.


;-------------------
;1/6/10 Snow day...
;CHANGES TO UI
I used to display about 15 different stats and variables for each bot when they were clicked on. Now, only 6 vital statistics
are shown, and I changed 4 of those to bar graphs instead of numbers. Much cleaner looking and pleasing to look at.
I also changed the readout for food. They too, are now represented by a bar length.

;PERMANENT COLORS
I was getting bot colors close to the food node colors so I put permanent colors in place. Each bot strain will be the same
color every simulation. So now, strain 1 will always be orange... time and time again. The only thing that is still
random for color is mutated strains.

;CURSOR
Added a flashing cursor to the currently selected bot or food. It was difficult to tell what you had selected sometimes.

;------------------
;1/7/10
Added carnibot. (carnibot = carniverous bot) Carnibots only eat botz from group A. They will spawn sometimes when
bots outnumber plants. They have short life spans compared to most bots. They are also just a wee bit faster. Omnibots
are obviously scared of carnibots, and will flee when a carnibot approaches.

Modified the omnibot flee code to make it look right. Tested it many many times. Had a bit of a headache but figured
a good solution out.

;------------------
;1/8/10
;NON-ENTERABLE SHELTERs
Adjusted the code for bots not being able to reach their shelter. (like if it's blocked by another shelter) Unfortuneatly
for bots the way they choose their home location is random, and sometimes they place it on other shelters. This makes
it impossible for them to return there, and thus impossible to reproduce themselves. So I have fixed this. Now when a bot
doesn't make it home within a reasonable time, he MOVES his house instead of tearing it down. He then tried to immediately
re-enter the home at it's new location. If this is still blocked, he'll move it again, and again, and again. This is much,
much better than the older code I had where they simply tore it down and waited to get hungry again.