Simulating Life

Just another UMass Boston Blogs site

Dom’s Code Review 3/3/17

| 1 Comment

Why is it done this way?

I decided to code in an egg count to simulate Chinook migration because coding in the Chinook mating, migrating, laying eggs, hatching of fry and the fry migrating to ocean would just be too complicated. With the egg count method, it eliminates all the messy code that would be required and essentially does the same job for the simulation (it just doesn’t look as cool).

Basic background on Chinook breeding:

Chinook normally breed around September to December. They lay their eggs and guard them (~25 days) they eggs hatch (~90~150 days depending on temperature)  then the fry stay in the spawning beds (12 months~18 months).

The code:

Left Picture: When Chinook collide during season 4 (~September~December) depending on their age groups, they either “add” 4 or 15 eggs to the egg count and the parents are deleted. In the simulation this simulates the Chinook mating and laying the eggs,  because season 4 is about 120 days  long this constitutes the laying and hatching times. This is under the prey tab.

Right Picture: When the egg count is x=0 it sets the egg timer to y=0, when the egg count is x>0 then the egg timer gets set to y=y+1 per tick until the egg count is x=0 again. Once the egg timer is y>=40  the simulation spawns the eggs depending on the number in the egg count data box. These Chinook are set to speed 1, size 1, age 1 and energy 35. This constitutes the staying in the spawning beds for ~12 months. Additionally the Chinook spawn in the top left corner (49,-49). Because season 4 is consider ~September~December and that is the laying and hatching of the eggs, during season 4 the eggs are affected by temperature. If the temperature is x<=25 10% of the eggs die (rounded up to the nearest whole number), at temperatures 26<=x<=57 the eggs are fine, at temperatures 58<=x<=74 75% of the eggs die (rounded up to the nearest whole number), at temperatures x>=75 all the eggs die. This is under the world tab.

 

One Comment

  1. left code
    – there’s no need to test twice if it’s in season 4; you can put the bottom preyAge test right below the top one and inside the first season 4 test
    – you should set the prey databox to the count of prey in a forever loop in the world – that will work better
    otherwise, it will do what you said – more eggs from younger fish
    you might want to reduce their energy when they lay eggs so they can’t just keep making tons of eggs

    right code:
    first code can be simplified to
    if egg count data box = 0 {
    egg timer databox = 0
    } else {
    egg timer = egg timer + 1
    }

    the rest is right – nice job on some complex code!

Leave a Reply

Required fields are marked *.


Skip to toolbar