A terminal function is an executable leaf in a genetic-programming routine. Unlike operators that combine expression inputs, it performs an action or supplies behavior without receiving expression arguments. In the ant simulator, terminal functions move or turn the agent, while the generated routine obtains its state from the simulator as it runs. section 12.4
Build a terminal-function set by registering concrete simulator methods:
- Create a primitive set with zero expression inputs when the generated code reads its required state from the environment. section 12.4
- Let higher-level operators invoke the terminal arguments; prog2 and prog3 sequence actions, while if_then_else selects between them. section 12.4
Ant movement terminals
The ant simulator exposes move_forward, turn_left, and turn_right as terminal functions. Each checks the move limit, updates the ant's state, and returns no output. A compiled GP routine repeatedly calls these terminals until the simulator reaches its move limit; fitness then counts collected food.
