Two roads diverged in a wood, and I--
I took the one less traveled by,
And that has made all the difference." —Robert FrostIt may not seem like a free-willed thinking agent, but our previous program made a decision—sort of. It chose between two possible actions, either to increase Mouse's speed or to not increase Mouse's speed. It made this decision many, many times depending on whether Cat and Mouse were touching.
I took the one less traveled by,
And that has made all the difference." —Robert FrostIt may not seem like a free-willed thinking agent, but our previous program made a decision—sort of. It chose between two possible actions, either to increase Mouse's speed or to not increase Mouse's speed. It made this decision many, many times depending on whether Cat and Mouse were touching.
Quiz Show
Blocks
The most basic type of conditional block is the if block. Sometimes, computer scientists refer to these types of instructions as branching. The following diagrams provide a visual explanation:
Consider a basic computer program much like the ones we've written up until now. The computer executes one instruction, then moves on to the next — the one immediately following it:
Consider a basic computer program much like the ones we've written up until now. The computer executes one instruction, then moves on to the next — the one immediately following it: