Welcome to session on Complexity Explorers basic tutorial agent based modeling in Python. In this session we’ll start the first of four sessions that focus on moving our agents across the Sugar scape landscape so they can identify the best location to move to in order to survive and thrive. So, let’s get started. Please open up your [SOUNDS LIKE] Google Collect Instance and so to start wanna make sure that your Sugar map that .txt file is available to your Google drive either by mounting your drive or by manually uploading it through the file system alright, then we can import our dependencies [SOUNDS LIKE] tutorially be using this. You also have the option if you [SOUNDS LIKE] edit header to collapse that alright and then have our Sugar and Spice Resource Classes where they grow one unit per step and we could collapse that where both of those [INDISCERNIBLE] Here’s our Trade Agent where we’ll spend the majority of the rest of this tutorial building out our agent behaviors and then our instantiation of the Model Class where there’s a lot of code to instantiate our environment and then from our last lessons to step our Sugar and Spice. Right. Just to make sure that it’s still working from the last time what we’ll do is we’ll run our class, right, run our instantiation that model. It still seems like it’s all working. So for this one we can just move down to one step count and get rid of this print statement, right, and now we’ll focus on how we step our agents so again we’re using a pretty unique step tool that we can use Mesa step functions as well as customize it one of the advantages of Mesa. Alright so the first thing we need to do is build out our move step function, right, and the trick here is that how agents move matters, right, so this reference “Who Goes First” by Dr. Kenneth Comer out of George Mason really is a great study on why the agent order actually matters and could produce different results based off what activation machine you decide. This case we use random activation to make sure there isn’t first mover or second mover advantage or any other type of [SOUNDS LIKE] agent advantage. Now the trick with this is that our agents can die, right, and per Python you can’t- If you’re iterating through a dictionary and you start removing keys that, that produces a run time error right so we need to set the conditions that we can remove agents at each step if they in fact you know run out of energy and effectively die and need to be removed, so to do that what we have to do is first get our list of trader agents, so using Python or correction Mesa’s activation by type just like we did for Sugar and Spice we will get all, a list of our trader objects. Right, so if we do values this would give us a list of trader agent objects, right, so our next thing we wanna do, right, is wrap those in a list so that way we can iterate through it more efficiently and remove agents, ok, right, and so then with that list, right, and actually if you look at this we got traders. We got capital T trader, right. It’s always good to try and make your, naming your variables as clear as possible so as traders it’s probably a little bit too ubiquitous throughout this, throughout the code we have so far. Alright, we’re gonna change this to trader shuffle just to make a little bit clear and more readable for anybody else that may take a look at this code. So now we have trader shuffle, right. Comments are always good so we wanna explain to any user you know what we’re thinking here and as well as to remind ourself why we had to you know make these choices, so in this case we wanna account for agent deaths and removal, right, which I, if we did purely in the Python dictionary structure would result in a run [INDISCERNIBLE]. So, we’re gonna make some notes to that effect and now that we have our list of trader agents, right, we wanna randomize it to account, to kinda mitigate any type of mover advantage based off their position, right, so it could use Python’s primitive random library and shuffle, right ,and then just put in our list trader shuffle. Now if we look at the documentation for that we know that it actually doesn’t return anything. It just takes that object where it’s, that list object where it’s stored and shuffles it all up, so just by running this command we know that, that that list of trader agent objects will be, will be read [AUDIO CUTS OUT] that we’ll build here in just a second, a second. So right what we’re doing is we create a list of our trader agent objects right and then we shuffle that list so that every time we run a step function each agent is in a different move [INDISCERNIBLE] right so this will be a function, this agent.move is now a function that we have to build in our trader.class. So, run that and then we’ll go up to our trader class, right, and we’ll add this function into our trader class. So, this is our initialization of our trader class right and so now we build the move function, right, so it’ll just be “def move”, right, and then “open parentheses self close parentheses”. Alright and now for this one we just wanna make sure that our Model Class calling our trader class is working, right, so we’ll just add a print statement, maybe a little bit more verbose than necessary but it says “I am and agent”, then to make sure it’s iterating through each of the agents and am about to move, right, and we use Python’s dot format syntax, right, so we put curly braces for where we want to put the variable and then we’ll have it call it “self.unique_id” so that way we know it’s changing agents so that, as it iterates through that alright and so this will allow us to kinda test to make sure that our calling of the, our calling of the move function is in fact giving us a randomized list of our agents. So, run that. Ok, store it in memory, right, then we go down to where we call our Model Class and it instantiate it and run it once, alright, and sure enough we get a, sure enough we get a, you know, a randomized list of our agents and if you want you could clear that out, put, and if you also want you can save a copy of this [SOUNDS LIKE] so we store it there. Alright, so that wraps up session nine alright, on our first part of moving agents, right, and in the next three lessons we’ll have them identify where to go based off their best choice in order to survive and thrive within the Sugar and Spice landscape. See ya next time.