Flowcharts#

Learning goals
  • translate a process into a flowchart

Mission: Safe landing#

https://gymnasium.farama.org/_images/lunar_lander.gif

Fig. 8 Lunar lander trying to land#

Problems:

  • limited fuel 🌡️

  • crash if high speed 💥

How do we control ❓

Flowcharts#

We can use flowcharts to represent the process of safe landing.

flowchart

a type of diagram that represents a workflow or process

        flowchart LR
    A(Start) --> B[Look at the clock]
    B --> C{
        is time >= 12:00 
        and time < 12:30?}
    C -->|No| D{
        is time >= 19:00 
        and time < 20:00?}
    D -->|Yes| E
    C -->|Yes| E[🍽️ Eat]
    D -->|No| F[🖥️ Work for 25 minutes]
    F --> G(End)
    E --> G
    

Tip

Draw the flowchart top to bottom, if you prefer.

Main symbols:

Table 1 Meanings of shapes#

name

shape

process

▯ (rectangle)

decision

◇ (diamond)

start or ending

(rounded rectangle)

If you heard of activity diagrams: Flowcharts are a basic form of them.

Activity 1

Draw a flowchart for the following program

  • if the altitude is higher than 100

    • the thruster must be off.

  • if the altitude is lower than or equal 100

    • turn on the thruster

  • if the altitude lower than or equal 0 (landing)

    • the thruster must be off.

Steps:

  1. 8 min work individually.

  2. 2 min compare with your partner’s.

Tip

Tools for drawing flowcharts:

  • Visual: draw.io. On the tools bar, there is a drop-down for flowchart symbols.

  • Declarative: Mermaid. Select Flowchart from the sample diagrams.

Appendix#