In AP Computer Science A, a simulation is a program that models a real-world process by repeatedly updating variables (state) with loops and making decisions with conditionals, sometimes using random values, like the 2024 FRQ that simulated birds and a bear eating from a feeder.
A simulation is code that pretends to be something in the real world. Instead of actually watching birds eat from a feeder for ten days, you write a loop that runs ten times, and inside that loop you update a variable that tracks how much food is left. The variable is the state of the simulation, and each pass through the loop is one step of time (a day, a hop, a level of a game).
Every simulation on the AP exam is built from the three algorithm building blocks in EK 2.1.A.1: sequencing, selection, and repetition. Repetition (a for or while loop) moves the simulation forward step by step. Selection (an if statement) decides what happens at each step, like whether a bear shows up or whether the frog reached its goal. Sequencing makes sure those updates happen in the right order, which matters because EK 2.1.A.5 says the order of these pieces changes the outcome. Many simulations also use Math.random() to model unpredictable events, but randomness is optional. A traffic light cycling on a fixed timer is still a simulation.
Simulation lives in Unit 2 (Selection and Iteration), Topic 2.1, and directly supports learning objective AP Comp Sci A 2.1.A, which asks you to represent real-life patterns and algorithms that involve selection and repetition. Simulation is where that objective stops being abstract. "Repetition is when a process repeats itself until a desired outcome is reached" (EK 2.1.A.4) is literally what a frog-hopping simulation does, hopping until it reaches the goal or runs out of hops. On the exam side, simulation is arguably the highest-stakes word in the course. FRQ Question 1 (Methods and Control Structures) is a simulation question year after year, so being comfortable with the loop-update-decide pattern is worth real points.
Keep studying AP® Computer Science A Unit 2
Selection (if statements) (Unit 2)
Selection is how a simulation makes choices. In the 2024 bird feeder FRQ, an if statement decided whether a bear ate everything or birds ate a normal amount. Per EK 2.1.A.3, the program branches based on a true/false decision, often one driven by Math.random().
Repetition (loops) (Unit 2)
Loops are the engine of every simulation. Each iteration represents one unit of time, like one day of feeding or one hop of the frog. A while loop is the natural fit when the simulation runs "until a desired outcome is reached" (EK 2.1.A.4), like the frog reaching its goal.
Algorithm building blocks and ordering (Unit 2)
EK 2.1.A.5 warns that the order of sequencing, selection, and repetition changes the result. In a simulation this is painfully concrete. Checking whether food ran out before subtracting what was eaten gives a different answer than checking after, and FRQ graders notice.
Simulation is the classic setup for FRQ Question 1. The 2018 exam simulated a frog hopping toward a goal, 2022 simulated playing and scoring a three-level video game, and 2024 simulated birds (or a hungry bear) eating from a feeder. In each one, you write methods that run a loop, use conditionals to handle different cases, and update state variables along the way. Multiple-choice questions test the same skill from the reading side. A typical stem gives you a short simulation, like a traffic light that increments a timer by 5 each loop iteration and resets after hitting 15, and asks what gets printed. Your job is to trace the loop carefully, tracking every variable on each iteration. The two skills to drill are writing the loop-decide-update pattern from a spec, and hand-tracing someone else's simulation without losing count.
Randomness shows up in lots of simulations, like the 2024 FRQ where a bear arrives with some probability, so it's easy to think simulation means random. It doesn't. A simulation is the overall model (state plus loops plus decisions), and Math.random() is just one optional ingredient for modeling unpredictable events. A traffic light simulation on a fixed timer has zero randomness and is still a simulation. Flip side, a single call to Math.random() with no loop or state isn't really a simulation, just a random value.
A simulation models a real-world process in code by repeatedly updating state variables inside a loop and using conditionals to decide what happens at each step.
Simulations are built from the three algorithm building blocks in EK 2.1.A.1: sequencing, selection, and repetition.
FRQ Question 1 on the AP CS A exam is consistently a simulation question, including the 2018 frog hopper, the 2022 video game, and the 2024 bird feeder.
Randomness via Math.random() is common in simulations but not required; a fixed traffic light cycle is still a simulation.
The order of operations inside the loop matters (EK 2.1.A.5), so checking a condition before versus after updating a variable can change the entire result.
To trace a simulation in a multiple-choice question, track every variable's value through each loop iteration rather than guessing the pattern.
A simulation is a program that models a real-world process by running a loop where each iteration represents a step of time, updating variables that track state and using if statements to handle decisions. The 2024 FRQ's bird feeder, which tracked remaining food over several days of feeding, is a textbook example.
No. Randomness models unpredictable events, like a bear showing up at a feeder, but plenty of simulations are fully deterministic. A traffic light that increments a timer by 5 each loop pass and turns red at 15 is a simulation with no randomness at all.
Every simulation is an algorithm, but not every algorithm is a simulation. A simulation specifically mimics a real-world process over time, with loop iterations standing in for time steps and variables standing in for real-world quantities like food remaining or distance hopped.
Yes, heavily. FRQ Question 1 has been a simulation in recent years, including a frog hopping toward a goal (2018), a single-player video game (2022), and a bird feeder (2024), and multiple-choice questions regularly ask you to trace simulation code.
Use a for loop when the number of steps is fixed, like simulating exactly 10 days of feeding, and a while loop when the simulation runs until a condition is met, like a frog hopping until it reaches the goal or runs out of hops (EK 2.1.A.4).
Connect this key term to the AP exam workflow: review the course, practice questions, and check related study tools.
Review units, study guides, and course resources.
Check this vocabulary in multiple-choice context.
Apply key concepts in written AP responses.
Estimate the exam score you are working toward.
Review the highest-yield facts before practice.
Put the full course together before test day.