Dark theme

Containers


This practical we're going to use containers to better store our agent coordinates, we'll still end with a lot of code, but we'll sort that out in the next practical; putting our agents in containers is the foundation. We'll also look at some neat functions for working with numbers in containers.


 

Our sequence this practical will be:

  • shift our coordinates into lists;
  • do some analysis on our coordinates;

First up, make sure you take a backup copy of last practical's code. How did you do with randomizing the starting locations? Here's one solution for the first coordinates...

y0 = random.randint(0,99)
x0 = random.randint(0,99)


  1. This page
  2. Making lists I <-- Next
  3. Making lists II
  4. Using functions