The basic problem appears to be that you increase speed every tick but don't have any code to stop growth. Here is one way to do it - you just have a test to see if the shark is fully grown:
to go
update-plots
tick
ask sharks
[ set Btimer (Btimer - 1)
forward Energy / 7
right random 80
left random 80
ask fishes [ die ]
if energy <= max-energy ; here is where you set the condition
[ set Energy (Energy + 7) ; also increases speed
set size size + 0.1
]
]
ask sharks ; There must be an ask here, otherwise error message
[ set Energy (Energy - 1)
if (Energy <= 0) [ die ]
if any? sharks-on patch-ahead 0 and Btimer <= 0
[ ask sharks-on patch-ahead 0
[ set Btimer (Btimer + 400 - random 200)
set Energy (Energy - 50)
]
hatch 10 [ ]
]
]
end
But this is primarily a design issue - what are you trying to represent with stopping the growth? Is it that the shark has become an adult, in which case a condition like the one I have inserted is the right approach.
Or is it that you expect growth to stop naturally for some other reason? For example, you might be thinking that the shark will stop growing because it runs out of food. However, the growth happens whether there is food or not. If you wanted the growth to happen only if there is food (fish) where the shark is, then you would do something like this:
to go
....
ask sharks with [any? fishes-here] ; restrict to sharks with food
[ set Btimer (Btimer - 1)
forward Energy / 7
right random 80
left random 80
ask fishes-here [ die ] ; since they are shark food
set Energy (Energy + 7) ; max not required, grows if food available
set size size + 0.1
]
....
end
Just a general comment, agent-based models are hard to debug because the complex interactions between agents, environment and behaviour means that it is not always clear which bit of the code is causing a problem, and the logic can be difficult. The best way to deal with this is to code in smaller pieces - just add the minimum change and make that work before writing anything else. For example, the way you have the code written, all fishes die immediately. That is a different problem. If you write only one piece at a time, then you only ever have one problem and you know what is causing it.