Chemotaxis - Sid Tamm informed me how bacteria are thought to behave during chemotaxis. The bacteria reach the food source (in this case, the mouse position) because they tumble more frequently when they are moving away from the food source and less frequently when moving towards the food source. In this animation, they do not tumble when moving directly towards the mouse, go into a tumble 100% of the time when they are moving directly away from the mouse, and otherwise go into a tumble with an intermediate probability that is proportional to the vector component along the bacteria - food source direction. This animation was written as an object oriented program and the source code is available.
In another version, you can vary the movement and decision parameters for up to three separate populations of bacteria. One parameter is the probability of starting a tumble when the bacteria is moving directly toward the mouse, and the second parameter is the probability of starting a tumble when it is moving directly away. You can also set the probability of coming out of a tumble - this determines how long the bacteria tumbles.
---------
Another version of "chemotaxis" - bacteria travel in a straight line, tumble to sample the environment, then set off in a new direction that is towards the food gradient - this is not how real bacteria behave. In this animation, bacteria move towards mouse cursor or can be switched to move away from the cursor. The "tumble frequency" is how often the bacteria stop moving in a line in order to check which direction to move in - 0.15 means that there's a 15% chance every time step that they will tumble. If the tumble frequency is 1.0, they won't ever move. The "decision frequency" is just how long they tumble. 0.3 means that there is a 30% chance that they will make their decision for every time step. If it is 0, they will never come out the tumble stage, and if it is 1, they will decide but won't tumble at all. The "bias" has to do with what variation they move towards the mouse. If the bias is 0, the bacteria will move directly towards the mouse. When it is at 180, they will move in a random direction ± 90° to the left or right of the mouse. When it is at 360, they won't have any net movement towards the mouse at all.Comparison - this compares this chemotaxis behavior with the more realistic behavior.