Trolley Problem

In this lesson, we reviewed coordinates, relative measurements, variables, movements, and how to use the mouse. We then covered Boolean values and conditional statements.

The Road Not Taken by Robert Frost: Two roads diverged in a yellow wood, And sorry I could not travel both…

This reminds me of th famous trolley problem: to do nothing -- killing five, or click the switch -- killing only one? So I made this sketch to visualize this moral decision.

https://editor.p5js.org/rootallroot/sketches/C7Aph6yCY

截屏2026-09-17 21.30.23.png

<aside> 💡

1. Which choices are easier, harder? Which choices are false choices?

</aside>

Doing nothing is easier because I don’t need to take any action. Clicking the switch is harder because I actively make a choice that affects someone. In this sketch, there is no perfect choice because someone gets hurt either way.

<aside> 💡

2. What internal or external factors influence the choice? How do others’ choices affect your choices?

</aside>

The number of people on each track influences my choice. I might also be influenced by what other people choose, especially if most people make the same choice.

<aside> 💡

3. What choices surprise you with unexpected outcomes?

</aside>

Clicking the switch feels like a simple action, but it changes the trolley’s direction and decides which group it reaches. The small interaction has a much bigger consequence.

<aside> 💡

4. Can you combine choices to create hard-to-predict results? (Hint: Use && and ||)

</aside>

Yes. I use && to check both the mouse X and Y positions, so the switch only works when I click inside the correct area. I could also use || to add another condition that changes the trolley’s behavior.