Part 1 mini-project: A flowchart for a real program
The first mini-project has no code. It is a flowchart, drawn on paper, for a real program — proof that you can plan a whole program before writing it, using the three patterns from Chapter 03.
What to build
Pick one of the following:
- A small game (Rock-Paper-Scissors, Hangman, a memory game).
- A daily routine (your morning, your bedtime, getting ready for school).
- A chore with a clear stopping point (washing the dishes, walking every dog in the house, watering every plant on a shelf).
Draw a flowchart for it on one sheet of paper. It must contain all three patterns from the previous chapter:
- Sequence: at least two actions in a row.
- Decision: at least one diamond with a yes-branch and a no-branch.
- Repetition: at least one arrow that points back to an earlier step.
That is the whole spec. There is no starter file — just paper, a pencil, and an eraser.
Worked example: Number Guessing Game
The Number Guessing Game from Part 4 (which you will code in Chapter 18) has all three patterns. Its flowchart looks like this:
Find the three patterns:
- Sequence: pick a random number → set attempts to 0 → ask for a guess → add 1 to attempts sits at the top of the loop body.
- Decision: is the guess too low? and is the guess too high? are two decisions. Either branch loops back; the third path (neither low nor high) reaches Done.
- Repetition: the long arrow on the left, going back from Say "too low" and Say "too high" up to Ask the player for a guess, is a loop. The correct! case is the exit.
When you read the Chapter 18 code, you will recognise this exact shape:
repeat
attempts = attempts + 1
io.write("Guess: ")
guess = tonumber(io.read())
if guess < target then
print("Too low.")
elseif guess > target then
print("Too high.")
else
print("Correct! ...")
end
until guess == target
The repeat ... until is the loop arrow. The
if/elseif/else is the two decisions. The lines between are
the sequence in the loop body. The flowchart became code, almost step
for step.
How to check your own flowchart
When you finish, read it aloud while tracing your finger along every arrow. It should sound like an instruction sheet for a careful but clueless friend. If it sounds natural, the flowchart is probably good. If it skips a step, your finger snags right there.
Also check:
- Does every arrow eventually reach an end (a
( Done )or( End )box)? - Does every diamond have two arrows leaving it (one yes, one no)?
- Does the loop's question include something that changes inside the loop body? If the question never gets a new answer, the loop never ends.
Done?
When your flowchart passes the read it out loud test and has all three patterns, you are done. Show it to someone if you want — explaining your own flowchart is a great test of whether you understood it.
The next chapter — Chapter 06 — Setup — installs Lua and a code editor on your Windows machine. After that, you start turning flowcharts into real code.