Lab 3: Fireflies

Prelab:

Download the code package for the lab here.

Final clarification on Unity version: we will be using the 2019 LTS version from now on to fix IntelliSense issues that some people encountered. Since the 2019 LTS version is also regularly updated, your version might look a little different from what we have. Starting from this lab, we will be using the 2019.4.11f1 (LTS) version, which is the latest 2019 LTS version available when the lab is made available. So, in Unity Hub, make sure you have this version or a later 2019 LTS version installed. This can be done by simply going into Unity Hub -> Installs -> Add, then choose the 2019 version available under Recommended Releases or Official Releases.

Note: If you can’t use the 2019 LTS version for whatever reason, you can also try using a 2020 version to open the code package, though IntelliSense is not guaranteed to work if you do this.

 

Recall the following diagram from the reading on fireflies:

 

Feeling stuck? Here is a further description of the algorithm by Marton:

  1. Using the variables given, fill in the two blanks below with the options provided to complete the part of the code in the Charge() function for when the firefly should send the message to flash.

        • Your options are:
  1. The following diagram describes the flow of the firefly program. Arrows represent calls from one function to another.  Answer which of the following functions fits in each blank space.

      • Your options are:
      • (ignore the “IEnumerater” before each one. We will explain what that means during lab)

Lab:

Part 0: TA Demo of Coroutine

Part 1: Flashing behaviour

  1. Open the OneFirefly scene
  2. Open FireflyLightControl.cs
    • All the code you will be writing today will be in this file
  3. Implement functions by following the TODOs. Note that the we won’t be completing the sawFlash function until part 2.
    1. Charge function
    2. SendMessageToFlash function
    3. WaitToCharge function
  4. Test your firefly
    • At this point, your firefly should be flashing at a steady 1 second rhythm. Make sure this is working before moving on to part 2

Part 2: Synchronizing behaviour

  1. Implement the code for sawFlash function
  2. Test that sawFlash is working by clicking your left mouse to simulate it seeing another flash
    • For this part, it may be helpful to increase the delayMultiplier so things move a bit slower and you can test the different scenarios (early/late flashes)
  3. Open the MultipleFireflies scene
  4. Test the synchronization by pressing space to add more fireflies (note that going beyond 10-15 may cause lag if you are on a laptop)
  5. Show your TA before leaving lab.

Postlab:

Remember to include your code as part of your submission

  1. Compare the firefly to the ants in this video. How are the fireflies similar to the ants? Is the behaviour which results obvious from the lower level rules? (50 words or less)
  2. Compare the emergence/self organization model to the PSS model. Which one do you think is a better explanation of cognition and why? (100 words or less)
  3. (Optional) How do you think this lab could be improved for students in the future?