Course: CSCI 1250

Lesson: Computational & Algorithmic Thinking

Description: GitHub

# Initializing state
Initialize Master Shake mood to "Indifferent"
Initialize Master Shake state to "Idle"
Initialize Master Shake health to 100
Initialize Master Shake inventory with "Remote Control" and "Sofa"

# Game loop
While game is running:
    # Interactions between other characters
    If Master Shake detects Meatwad asking for help:
        Set Master Shake's mood to "Annoyed"
        Set Master Shake's state to "Ignore Meatwad"
    Else If Frylock is doing something productive:
        If Master Shake's health > 50:
            Set Master Shake's state to "Criticize Frylock"
        Else:
            Set Master Shake's state to "Goof off"
    Else If Carl is nearby:
        If Carl is eating:
            Set Master Shake's state to "Demand Food"
        Else If Carl is minding his own business:
            Set Master Shake's state to "Annoy Carl"
    Else:
        Set Master Shake's state to "Watch TV"

    # Performing actions based on the state previously set
    # You don't need `Else If` since the conditions are mutually exclusive
    # (The state can't be two different things)
    Perform action based on Master Shake's state:
        If state is "Ignore Meatwad":
            Roll eyes and do nothing
        If state is "Criticize Frylock":
            Say something sarcastic and unhelpful
        If state is "Goof Off":
            Dance around, make silly noises, and avoid any work
        If state is "Demand Food":
            Yell at Carl until he hands over his food
        If state is "Annoy Carl":
            Do something obnoxious to ruin Carl's day
        If state is "Watch TV":
            Sit on the sofa, watch TV, and ignore everything else
flowchart TD
    A1((Start))-->
    A{Is Carl Nearby?}--> |Yes| B{Is Carl Eating?}
    A --> |No| E[Watch TV]
    B --> |Yes| C[Demand Food]
    B --> |No| D[Annoy Carl]
    E --> F[Sit on Sofa and Watch TV]
    C --> G[Yell at Carl until he hands over food]
    D --> H[Do something obnoxious to ruin Carl's day]