Kodu Vocabulary for Teachers
David S. Touretzky, Carnegie Mellon University
page
Kodu programs are organized into pages. There are 12
pages available. Characters always start on page 1. Each page can
contain several rules.
rule
Each line of a kodu program is called a rule. Every rule has
a WHEN part and a DO part.
tile
Each rectangle that appears in a rule is called a tile. A
tile contains a picture and an associated word or phrase, e.g., the
"move" tile has a picture of a kodu with trailing lines suggesting
motion. On the screen we have virtual tiles. In the real world we
have physical tile manipulatives made out of acrylic.
Reading a rule aloud
When reading a rule aloud, always include the "WHEN" and the "DO"
keywords. They are essential parts of the rule, and they help
reinforce the syntactic structure of Kodu.
Wrong way: "bump apple eat it"
Right way: "WHEN bump apple DO eat it"
If the rule's condition is empty you can say "WHEN DO...", or "WHEN
always DO...".
Conditions, actions, and parameters
condition
The first tile in the WHEN part of a rule is the
condition. Examples include "see" and "bump". Conditions can
be either true or false, depending on the state of the
world, but they do not change the world. Students may need to be
reminded of this, especially with regard to "bump". Bump apple
means "felt a bump involving an apple", not "go find an apple and
bump it". An empty WHEN (no condition) is always true.
action
The first tile in the DO part of a rule is the action.
Examples include "move" and "eat".
parameter or argument
The tiles that appear after a condition or action tile are called
parameters or arguments. (These are terms from computer
science; for our purposes they are synonymous.) In the rule "WHEN see
red apple DO move toward", the "red" and "apple" tiles are parameters of
"see", and "toward" is a parameter of "move".
grammatical roles of tile words
In terms of English grammar, conditions and actions are always
verbs. Parameters can be nouns ("apple"), pronouns ("me" or "it"),
prepositions ("toward"), adjectives ("red"), or adverbs
("quickly").
indent
A Kodu rule is indented by sliding it one step to the
right.
parent
For a rule to be indented it must have a parent. The
first rule above it that is less indented is the rule's parent. Thus,
the first rule on a page can never be indented because it would have
no parent.
rule can run
An unindented rule can run if its condition is true. An
indented rule depends on its parent: it can only run if its parent can
run (and its own condition is true).
Idiom Terminology
idiom
In human language, an idiom is a phrase whose meaning is
established by convention and cannot be discerned from the literal
meanings of the individual words. Common English idioms include
"raining cats and dogs" and "miss the boat". In computer science,
an idiom is a commonly used and hence easily recognizable pattern of
computer instructions. Kodu idioms are idioms in this sense. An example
of a Kodu idiom is Pursue and Consume.
pursue To pursue means to quickly follow or
chase after. In Kodu, a pursue rule always involves some sort of
motion. A pursue rule can be the first half of a Pursue and
Consume idiom.
consume
To consume means to ingest (as people consume food), or
use up (as a car consumes gasoline or a fire consumes wood). In Kodu,
a consume rule either eliminates the object or changes it so that it
is no longer perceived by the pursue rule it is paired with.
default
A default is something that holds when no alternative has
been specified. For example, the default number of pickles on a
McDonald's quarter pounder with cheese is two. You
can have more or fewer if you ask for that. But if you don't ask, you
get two pickles by default. In Kodu, the Default Value idiom
specifies what parameter value to use with an action when no earlier
rule has specified a value.
conflict
Two Kodu rules conflict if they have the same action but
incompatible parameters. For example, "move toward" and "move wander"
conflict. If both rules can run, only one action will take effect.
Likewise, "color me red" and "color me blue" conflict.
earlier rule
A rule that appears earlier on the page than some other
rule will have a lower rule number, and will have priority if there is
a conflict.
priority
When two rules conflict and both can run, the earlier rule has
priority, meaning its action is the one that takes effect.
Thus, if rule 1 says "move toward" and rule 2 says "move wander", then
rule 1 has priority because it appears earlier on the page. Rule 2's
action will take effect only in situations where rule 1 cannot
run.
action takes effect
An action takes effect if it successfully performs its
intended function. For example, "eat" takes effect if it makes an
object disappear. The "eat" action might not take effect if the
object the character is trying to eat is too far away. An action
also might not take effect if a conflicting rule has priority over
it.
rule or action is blocked
A rule (or action) is blocked if some rule with higher
priority prevents the action from taking effect. For example, in the
Default Value idiom, if the rule specifying the special case runs, it
will block the rule that implements the default case.
State Machines
A state machine is an idealized, theoretical machine whose
behavior is described in terms of a start state, a set of additional
states, and a set of transitions from one state to another. State
machines are widely used in computer science to describe the behavior
of digital electronics (hardware) and the computer software that runs
on that hardware. State machines are theoretical ideals because
unlike real machines, their reliability is perfect: they can never
make an error, overheat, or run out of power.
state
A state machine is always "in" exactly one state at a
time. State machines perform computation by moving from state to
state. In Kodu, each character is a separate state machine, and its
pages are its states. There is another sense of "state" that is also
important: the state of the world. This includes the positions of all
the objects in the world, their properties such as color and size,
what they are holding, and so on. Conditions check the state
of the world to see if the condition is true, while actions change
the state of the world.
transition
A transition takes a state machine from one state to
another. Every transition has a condition associated with it. The
transition will only "fire" if the condition is true. In Kodu,
transitions are performed by rules with a switch to page
action.
start state
Every state machine has a start state that it occupies
when the computation begins. In Kodu the start state is always page
1.
Graphical notation for state machines
State machines are commonly drawn as diagrams composed of nodes
and links. In computer science terminology these diagrams are called
labeled directed graphs. State machine diagrams are a
convenient way to reason about state machine behavior, e.g., we can
tell if one state is reachable from another by looking for a sequence
of transitions forming a path between them.
state node or just node
A state node is drawn as a circle with text inside it
describing the state. In Kodu each state node should be labeled with
the page number of that state and a brief description of what the page
is trying to do, e.g., "Page 1: pursue and consume apples".
link
A link is drawn as an arrow connecting one state node to
another. Links describe the transitions between states. The arrow
should be labeled with some text describing the condition under which
the transition will fire, e.g., "reached the red tree" or "no apples
left". Since a node with no incoming links would be unreachable, in a
well-formed Kodu program every node (except possibly the start node)
has at least one incoming link.
terminal state
A terminal state is a state with no outgoing links. Once
a character enters a terminal state it can never leave that state. In
Kodu a terminal state will often contain a "(game) win" or "(game)
end" action.
|