POLS909 Topics in Methodology: Agent-based modeling March 15, 2000 Exercise 9.1 These exercises are intend to make you think a little bit about the Observer Swarm level of a simulation and what can be done with it. Begin with Heatbugs for whatever version of Swarm you have. I've tried many variations on these things, but I can't say that I have ready made illustrations just sitting around. So if it doesn't run after you compile it, you might let me see what you have done. 1. Change the colors of the bugs and the heat in the HeatbugObserverSwarm.m file. Look at the colormap. That is where the system finds colors when an agent does a drawSelfOn: method. You see some color numbers are assigned one-by-one, as are 64, 65, and when we want a color scale for the heat, we use the scale that combines the amount of red, green, and blue. The numbers for red, green, and blue must be between 0 and 1, inclusive. Note: in the faq, you can find a link to a list of allowed color names: http://lark.cc.ukans.edu/~pauljohn/SwarmFaq/SwarmOnlineFaq.html#3.11 2. Change the code in the Heabug.m so that the heatbug's chosen color can change over time. For example, the color might show the bug's level of unhappiness, or anything else. 3. Compile Heatbugs with the Pixmap support. I realize the README says: make CPPFLAGS=-DUSE_PIXMAP but on Swarm-2.0.1 in Windows, you have to add it like this: make EXTRACPPFLAGS="-DUSE_PIXMAP -DDLL" Run that, look it over. Notice how the pre-processor statement alters what the Heatbug does when it is told to draw itself. 4. This next step is strictly for entertainment, don't bother if it gives you a hassle: Find a picture editing program that can save images in png format, or you need a converter into png format. png is a free, open source alternative to gif. The Gimp image program can save png, and last I heard there was Gimp for windows. I don't know what other editors can output png format stuff. If you look for 30 minutes and can't find a free one, let the email list know and we'll concentrate on it. When I was a windoze junkie, there was a free editor called Lview-pro, I don't know what there is now. You might check www.dejanews.com/usenet. Make some png files, then rewrite the Heatbug.m file so that different bugs use different pixmaps. You could write it so the pixmap is assigned by the ModelSwarm. This step is just for fun, I've done it and it is entertaining. 5. Create more lines to be displayed in the graph output of the Heatbugs program. I think you could make the bug calculate a few more things, and give back information about them. Where you currently have getUnhappiness, for example, you could add methods to getIdealTemp or such. Then in the HeatbugObserverSwarm.m, you add those variables to the EZgraph. Its almost obvious what you do--just more lines like the unhappy graph. Swarm has built-in colors for the lines. If you don't like the colors, you can control them. I just added an entry in the SwarmOnlineFaq about how. 6. Try this: Get your Exterminator code from Exercise-8.1, and try to integrate it with Heatbugs. You can look at the examples in the Exterminator directory too. I think the Exterm3 is pretty close to what you want. When you compile with Pixmaps, Heatbugs should be ready to go, but the Exterminator class will need to be fitted in the same way with a pixmap. I will give you a pixmap for the Exterminator if you ask me. So you can see a raster with pictures of exterminators and bugs. I think that would be beautiful. 7. Take a look at the game of life. There are tons of web sites. A lot of them crash my web broswer. This one doesn't. This is a page where a java applet runs and you can color in some squares and watch the simulation proceed: http://cgi.student.nada.kth.se/cgi-bin/d95-aeh/get/lifeeng Here is another online life simulation. Works fine for me: http://www.mindspring.com/~alanh/life/ If you just want to test drive a CA model. Here are a page on CA that does work: http://www.cs.jhu.edu/~callahan/lifepage.html Just about everything worth knowing can be found there, or in links from there. If you want to write rules for CAs, there are specilized CA packages for windows. 1. Life32 for Windows 95/98/NT by Johan Bontes(http://psoup.math.wisc.edu/Life32.html). According to Alan Hensel, "This is the best Life program for 32-bit Windows. It's extremely fast, powerful, and easy to use. Highly recommended!" Don't forget to get some "Life patterns" while you are on that page. You must have them, they are like "document" files that give rules for your ca. The Hensel package of rules is cool! If you don't like that, maybe you like this: 2. Lou Gross, a well known ecologist at Tennessee, wrote this to me when I asked him "what is the easiest/best windows package for CAs and game of life": "Have you looked at Rudy Rucker's Cellab at http://www.mathcs.sjsu.edu/faculty/rucker/cellab.htm It is perhaps not the easiest to use, but most of the real easy ones don't allow easy changes of rules- they just display game of life or others and let students change starting sets." This one comes with some life rules and has a manual. It doesn't look as good as Life32.