Unrealistic animal birth

When i made my first creature, and when it reproduced first time i was surprised that the child location is chosen randomly from all over the terrarium. I see that it is not right, the child must be placed near his parent. In many means it will be reasonable. Firstly to protect young growth: the parent would be able to protect his children right away; the children could stick to parent till they grow as needed; it will reduce occurrences with child born in not habitable areas. Secondly it will open new strategic possibilities, e.g. "areas of living", so different areas of terrarium can be occupied by different species holding theirs strongholds. Therefore a lot of different creatures would have their chances to survive and prosper in terrariums, not only dominating ones.

Answer this question

Unrealistic animal birth

  • Glennpd

    Don't think that all here are clueless newbies. =)

    The algorithm can be optimized to search 1 empty cell instead of group, it comes from that in Terrarium creatures always have odd width and height sizes in cells because they have radius, therefore just add child's radius to all other creatures radiuses and voila! Fill the binary (empty = true, not empty = false) matrix. Then traverse matrix in best-first style starting the radius of parent radius + child radius from the parent position, searching for the first empty cell. Very simple.

    Again the birth isn't given by every creature by every tick, 3-4 times (ticks) average per creature's life!

    The significance of realistic birth shouldn't be underestimated.

  • ryan_gartner

    So how about adding realistic birth for next release  The code for searhcing nearest empty space for child should be pretty simple and take small computing time. So why not to implement it, as it can significantly improve the gameplay

  • DavidHanlon

    Wait a minute why radius doesn't matter  It's bounding boxes, not creatures sizes that goes into account when checking for occupied space. Well, maybe the algo i described wasn't  clear for you (optimization in it along with others optimizations is tested and working in my  A* pathfinding routine, that my creature issues every tick without time consume harm). I can submit the code if you want.

    > Once the Terrarium Source is released I'll just replace the grid system with a bounding circle
    > system which will make the concept of placing babies next to parents quite a bit easier,
    > along with speeding up the LOS algorithm (Scan), simplify path finding algorithms

    Ok, if you'll implement bounding circles in the next release i hope you'll implement new birth 
    scheme either. This and other improvements should push the app closer to real life simulation. 

    > and will remove the Bresenham implementation for grid cell locking that currently exists
    > and makes everyone's life a living h*ll

    But if you ask me i'll say that i get used to them. =)

    Say, what would happen after this great "source release", who would mainly support the terrarium development  What major features would appear  And when this release would happen

  • Bri68

    Actually, because of the density in most Terrariums, it can take hundreds of iterations of a loop to find a space big enough to fit a new creature.  This process is not nearly as easy as you would think.  Currently the Terrarium doesn't use any sort of space division algorithms, and finding an empty cell versus finding an empty collection of cells is actually quite difficult.  To test I recommend:

    Sit down and write an algorithm that iterates over a 10,000 x 10,000 array looking for 3x3, 4x4 and 5x5 groups of empty cells after you've randomly filled 40-75% of the space already with 3x3, 4x4, and 5x5 groups.  In many cases there doesn't even exist a single group of cells that fits the criterion because much of the remaining space is cordoned off into single cells or strange patterns.

    Once the algorithm is done, have your application run the algorithm 60 times every second.  That is basically what the Terrarium is doing during normal operation.  In addition, unless the algorithm operates at blazing speed, it can't be used.  It basically needs to consume only about 10 or 20 milliseconds of game time every second.

  • Ed.S.

    Hehe, you'd be surprised.  It took about 8 months after the release of the Terrarium before we finalized all of the documentation and finally documented the grid system.  A lot of users didn't understand the intriciacies, and many user's still don't based on some of the code I've decompiled.

    I'd say it sounds like you know your way around some of the internals.

  • JB-Bellevue

    Alrighty, I'll bite, even though I don't have control over future Terrarium releases...

    So first off, the Terrarium already has a grid system that is integral to about 15 different internal algorithms, so it can't be changed.  The grid system is aligned on 8x8 pixel boundaries, and creatures during their lifetime will take up from 9 to 25 of these cells at any given time.

    The alogrithm would never actually take into account parent radius or child radius because these numbers don't matter.  However, since each child actually takes up 3x3 cells or 9 cells the algorithm gets pretty hairy, simply finding a single empty cell won't work.  You have to find a 3x3 grid of these cells in order to place a child.

    I won't say the algorithm isn't easy.  Not in the least.  However, it is time consuming.  Simply try it for yourself given the criterion I cited in the previous posting.  If nothing else I'll work out the code tomorrow sometime and post it.

    I do think it is a moot point for now.  Once the Terrarium Source is released I'll just replace the grid system with a bounding circle system which will make the concept of placing babies next to parents quite a bit easier, along with speeding up the LOS algorithm (Scan), simplify path finding algorithms, and will remove the Bresenham implementation for grid cell locking that currently exists and makes everyone's life a living hell.

  • Ajil

    Yep, we chose the *random* approach for sheer speed.  It was simply faster to find an unoccupied grid cell at random than to find a close-by empty grid cell.  It also prevents the need to *find empty space* when you reproduce.  This makes reproduction easier since you don't need to ensure there is room for child birth in your vicinity.

    Most of the issues here are because the Terrarium is implemented using a grid layout.  If we got rid of the grid and used bounding circles this wouldn't be an issue and it would be much faster to find a *close to parent* location than with the grid system.

    The largest issue with the grid system is *unused space* that is locked because of a small overlap in a creature's bounding box or a plant's bounding box.

  • PlumFighter

    Forgive me my inexactness, by radius i meant exactly the CellRadius, didn't think that anyone would want  to use the Radius for space checking. =)
  • lovely

    Radius never matters.  Radius is your actual size, while CellRadius is how many cells you occupy which is important since you use this number to determine what cells you block, not your radius.  To be precise in pathfinding you need to use CellRadius, while to be a little less precise you can use your Radius.  There are loads of algorithms on the Internet that describe how this works.

    I'd probably look at implementing the birth close to parent.  With bounding circles it becomes a lot easier and using a proper space subdivision algorithm (QuadTree), even if the immediate surroundings are blocked off you'll find some space for the new creature that is close to the parent much faster than the current algorithm randomly finds empty space.

    After the great "source release" I plan on working on the code and releasing updates weekly/monthly as I'm sure many other programmers are.  Independent developers will be responsible for their own source trees for support, so small community sites are going to have to be developed.  As for major features, that is up to the developer(s) working on their particular implementation.  When it happens I'm not sure, that is up to Microsoft.

    As far as different versions of the Terrarium go, I'm sure MS will continue to support some version of the Terrarium.  They may even take code submissions for future releases from the community and maintain an MS supported version of the game.  As for me, I'm just going to go all out on the code as spare time permits and won't bother working with the supported version since I have so many huge changes already coded that will make any versions of Terrarium I release drastically different from any source release MS does.

  • Unrealistic animal birth