Energy

How can I simulate an agent gaining and losing energy?Agent Variables in the Factory drawerAgent Variables in the Factory drawer

Solution: 

Agent Variables can be added to agents to give them additional awareness about themselves. A common variable is Energy. Agent Variables are blue. When an Agent Variable is created, it must go into the column of the breed that will have the variable and be given an identifying name. Agent Variables will then be found in the My Blocks column, in the drawer of the breed in which it was created. These Agent Variables can then become part of the code where needed.

In this example, the Agent Number Variable was used to create the Energy Variable.
Agent Variables in the My Blocks drawerAgent Variables in the My Blocks drawer
Set Energy- can be used when the agent is created to give it a certain amount from the beginning.

Inc Energy- is translated as ‘increment energy.’ Increment energy can be either by a positive or a negative amount. Often a number block is fit in next to the variable block.

Energy is used in Fish and Plankton. When a fish collides with a plankton it increases it's energy, and as it moves it loses energy:

Submitted by paige on 29. December 2007 - 17:55