VNUHCM
Previous lesson Next lesson
  • Learning content
  • Help
    Do you have any questions while learning?
    Learning instructions Frequently asked questions Email for support
    • Tiếng Việt
    • English
    • Member's information
    • Registered courses
    • Log out
  • Cohota
  • HƯỚNG DẪN HỌC TẬP

  • View detail >>
    You have completed 0% of the course
  • HƯỚNG DẪN SINH VIÊN ĐĂNG NHẬP HỆ THỐNG
    • Hướng dẫn đăng nhập
    • Hướng dẫn vào khóa học
  • Introduction
    • Welcome
  • Unit 1: Values
    • Introduction - Unit 1: Values
    • Get Started With Values
    • Play with Values
    • Playground Basics
    • Naming and Identifiers
    • Simulation
    • Strings
    • Constants and Variables
    • Word Games
    • Build a PhotoFrame App
    • Design for People
  • Episode 1: The TV Club
    • Introduction - Episode 1: The TV Club
    • Searching for Content
    • Sharing Personal Information
    • Ordering Online
    • Reflection: Episode 1
  • Unit 2: Algorithms
    • Introduction - Unit 2: Algorithms
    • Get Started with Algorithms
    • Play with Programs
    • Functions
    • Types
    • Parameters and Results
    • Making Decisions
    • BoogieBot
    • Data Visualization
    • Build a QuestionBot App
    • Design an Experience
  • Episode 2: The Viewing Party
    • Introduction - Episode 2: The Viewing Party
    • Accessing the Show
    • Streaming on the Network
    • Reflection: Episode 2
  • Unit 3: Organizing Data
    • Introduction - Unit 3: Organizing Data
    • Get Started with Organizing Data
    • Play with Complex Data
    • Instances, Methods, and Properties
    • Arrays and Loops
    • Structures
    • Enums and Switch
    • Testing Code
    • Processing Data
    • Pixel Art
    • Password Security
    • Visualization Revisited
    • Build a BouncyBall App
    • Design a Prototype
  • Episode 3: Sharing Photos
    • Introduction - Episode 3: Sharing Photos
    • Capturing Images
    • Posting on Social Media
    • Reflection: Episode 3
  • Unit 4: Building Apps
    • Introduction - Unit 4: Building Apps
    • Get Started with App Development
    • Play with App Components
    • Color Picker
    • ChatBot
    • Rock, Paper, Scissors
    • MemeMaker
    • Build an ElementQuiz App
    • Design for Impact
  • Appendix
    • Episode Technical Concepts
    • Glossary
Course overview
Assessment

Progress
Criteria name Weighting (%) Score Progress (%)
Unit 1: Values

Simulation

Unit 1: Values|Play

What you'll build

A simulation of an ant colony.

What you'll learn

  • How values are used as parameters of simulations to affect the way they run.
  • How to interpret the visual information in a simulation.

Key vocabulary

  • Simulation
  • Parameter
  • Bias

Introduction

Problems like weather prediction, drug research and design, and rocket dynamics are hard because they involve extreme scales of space or time, vast amounts of data, and potentially dangerous conditions. Computers allow us to simulate complex or dangerous environments to test hypotheses about their behavior.

In this lesson, you'll be experimenting with a simulation of an ant colony to learn how the parameters of a simulation affect behavior in the simulated environment. A simulation tracks large numbers of values as they change over time. In this case, each ant has a location, a speed, and a direction. There's also information in the simulation about the environment around the ants, such as location and amount of food. As the ant simulation runs, you'll see the virtual ants scurry around their environment looking for food to bring to the nest.

Parameters built into a simulation allow experimenters to vary its conditions—for example, the number of ants in the colony. In the playground, you'll be observing the behavior of the simulation and how it's affected when you modify its parameters. Parameters are expressed as variables in the playground—you'll modify them by assigning them different values. Each page will explain the names of the parameters and how they affect the simulation.

Go Build

Open the Simulation.playground file in your course resources and follow the instructions.

Screenshot of the Simulation playground

Reflection Questions

The ant simulation replicates the foraging behavior of a colony. Aspects of an ant colony that aren't directly related to foraging can be discarded as irrelevant. For example, the underground existence of the colony's nest is abstracted away by representing the entrance as a location from which ants emerge and into which they drop off bits of food. Other aspects are present, like the grid of pheromone concentrations and food, but modeled much more simply than in the real world.

What other simplifications can you identify in the ant simulation?

Why do model designers make simplifications?

How do they decide which parts of the real-world system to discard in their design?

How might you extrapolate from hypotheses about a system to the simplifications you'd design into its model?

Simplifications come with tradeoffs. The bias of a simulation is directly related to its simplifications. Simulation bias affects how accurately you can make predictions about the system it represents.

How does the size of environment cells bias the ant simulation?

What other forms of bias exist in the ant simulation?

Summary

You've seen how single values can have a very large impact on a program. Just by changing the value of one of the parameters of the ant colony simulation, you could cause the behavior of the colony to change.

This simulation is a program, its parameters such as numberOfAnts are inputs, and its visualization is the output. The simulation is dynamic—it changes over time. Inside is some complex code that uses the inputs to model how ants search for food.

All the values you've seen so far are numbers. In the next lesson, you'll learn how Swift lets you work with text.

Report error