The queen inside the hive can give birth to more ants if enough food is gathered. After an ant has harvested food somewhere, it has to deposit it in its hive.
To transfer food from an ant to the hive or another ant, the transfer command is used.
Transer command
The command looks like this:
[ActionType.TRANSFER, <object>, <amount>];
// examples:
[ActionType.TRANSFER, otherAnt, 10]; // transfers 10 food to 'otherAnt'
[ActionType.TRANSFER, hive, 25]; // transfers 25 food to 'hive'
The ant has to be in front of the receiving object and has to be rotated towards it. Otherwise it cannot transfer food.
Tip:
While an ant carries food, it sometimes snacks a bit from it. This increases the ants vitality and therefor its lifespan a bit. On the other hand though, the amount being carried gets less and less after time...
Try it yourself!
A little hands on:
Based on a working code for the previous tutorial, add the command to transfer food to the hive!
Once the hive has enough food, another ant is born.