/users/rlr/Courses/ICPSR-02/SimpleModel1/notes.txt -------------------------------------------------- A simple model to show some basic features of Swarm, and to act as a starting template for more complicated models. This model has one type of Agent, living in a 2D (torus) world. In this version, each agent: - wanders around randomly, by trying to move one cell over in a randomly selected direction. But if the selected cell is occupied, the agent stays where it is. - picks one of its (up to) 8 neighbors at random, and plays one round of a PD with that other agent. Each agent has a value i, which is its probability of cooperating. So if each have i=1, they both cooperate; each each has i=0, they both defect. After they play (using the usual 5,3,1,0 payoffs) they each increment their wealth by the resulting scores. Thus the Agents have: ID - arbitrary identifier x,y - location in grid i - probability they cooperate wealth - cummulative score numberOfMeetings - a count of times they have met (and played) some other The ModelSwarm-buildObjects method is where agents are created and placed in the world and on the agentList. The ModelSwarm-step method is where agents are activated, i.e., sent the step message themselves. The agentList is shuffled each ModelSwarm-step, so they are activated in a new random order each step. The Agent-step method currrently just calls the Agent-makeRandomMove method to try to move, and then it calls the Agent-getRandomNeighbor to see pick a neighbor to play, and then if there is another to play, it calls the Agent-play method to actually play. Note both agents have their wealth and numberOfMeetings incremented when they play. Values written to the report file (and plotted on GUI) are: - average wealth per meeting - average wealth per time step From this simple program, there are many directions one could go. For example: - Add an adaptive mechanism, along the lines of Epsteins demographic PD. - All the agents to play multiple rounds when they meet. This would most likely involve a new space of possible strategies. - Giving the agents the ability to refuse to play, e.g., based on reputation or tags. - Give them the ability to move in non-random ways, e.g., if they can see agents with good reputations, or particular tags, or some other feature of agents (or the world). Of course one could also change the agents so they are not playing PD at all, and have them interact in some other ways. ==================================================================== To establish a copy of this in your home directory: cd ~ mkdir SimpleModel1 cd SimpleModel1 cp /users/rlr/Courses/ICPSR-02/SimpleModel1/*.h . cp /users/rlr/Courses/ICPSR-02/SimpleModel1/*.m . cp /users/rlr/Courses/ICPSR-02/SimpleModel1/Makefile . cp /users/rlr/Courses/ICPSR-02/SimpleModel1/*.txt . Then to compile and link it enter: make If there are no errors, enter ll and you should see something like: -rw-r--r-- 1 rlr car 1069 Jul 24 23:40 Agent.h -rw-r--r-- 1 rlr car 5556 Jul 24 23:41 Agent.m -rw-r--r-- 1 rlr car 60120 Jul 24 23:41 Agent.o -rw-r--r-- 1 rlr car 649 Jul 24 17:59 BatchSwarm.h -rw-r--r-- 1 rlr car 3246 Jul 24 18:00 BatchSwarm.m -rw-r--r-- 1 rlr car 57064 Jul 24 22:49 BatchSwarm.o -rw-r--r-- 1 rlr car 1521 Jul 24 17:42 main.m -rw-r--r-- 1 rlr car 51164 Jul 24 23:40 main.o -rw-r--r-- 1 rlr car 2081 Jul 24 22:20 Makefile -rw-r--r-- 1 rlr car 736 Jul 24 22:44 ModelSwarm.h -rw-r--r-- 1 rlr car 7452 Jul 24 22:51 ModelSwarm.m -rw-r--r-- 1 rlr car 65776 Jul 24 22:52 ModelSwarm.o -rw-r--r-- 1 rlr car 1459 Jul 24 23:23 notes.txt -rw-r--r-- 1 rlr car 818 Jul 24 18:01 ObserverSwarm.h -rw-r--r-- 1 rlr car 10033 Jul 24 23:12 ObserverSwarm.m -rw-r--r-- 1 rlr car 73200 Jul 24 23:12 ObserverSwarm.o -rw-r--r-- 1 rlr car 366 Jul 24 22:20 Parameters.h -rw-r--r-- 1 rlr car 3051 Jul 24 22:35 Parameters.m -rw-r--r-- 1 rlr car 53596 Jul 24 22:40 Parameters.o -rwxr-xr-x 1 rlr car 6505 Jul 24 23:41 sm1 You can then run the model ./sm1 & The usual Swarm widgets should pop up. As with Tipping, Axelcult, etc, you can change parameters on the run command: ./sm1 -DnumAgents=5 & or run in batch mode ./sm1 -DstopT=100 -b & To see a list of parameters: ./sm1 -Dh ============================================================================