Table of Contents
| Creating Mugger Agents | 
| Criminal Behaviour | 
| Activity | 
 
        
        In this practical, the festival model will be extended by adding a new type of agent to represent criminals (called 'muggers') and by creating some interactions between different agents if they happen to bump into each other.
breed command - 
            if you can't remember how this command works check the
            NetLogo Programming Guide
            or refer to the last practical.victims' that the muggers will use
            to keep track of the number of people they mug. Hint: the muggers-own
            command will do this, as covered in the last
            practical.Now, NetLogo knows that there are two types of agents in the model. The next thing to do is actually create some muggers
number-of-muggers'.
            This will be used to set the number of mugger agents. You can choose the limits of the
            slider - I choose a limit of 100 and default of 10. 
            
            setup-muggers'.
            This procedure should create the new mugger agents and do three things:
            setup-muggers' procedure in the main
            'setup' procedure, just after the
            call to 'setup-people. By the end, your setup procedures will look similar
            to the right image. Sorry, the setup-muggers procedure has gotten smudged,
            you'll have to work out what goes in there on your own!The next stage is to implement some behaviour for the mugger agents. We need a procedure that will move the muggers around the environment and, if they come into contact with a visitor, commit a mugging.
show-crimes.
            This will be used later to turn on (or off) a label that shows where crimes have
            been committed.Next, we will create a new procedure that controls the behaviour of the mugger
            agents. There is already a procedure called 'move' that tells the visitor
            agents what to do at each model iteration. No we need a similar procedure that will
            tell a mugger to walk around the festival site and, if they come across a
            visitor, mug them.
move-and-mug'. This procedure will
            contain the code that we need to control the mugger agents.| Code | Explanation | 
|---|---|
| to move-and-mug | The procedure is called 'move-and-mug'. It will control where the agents go and make them mug visitors if they happen to meet on the same patch. | 
| rt (random 360)fd 1 | These commands make the muggers move around the environment randomly. They don't move between food stalls and stages like the visitors do. | 
| if count visitors-here > 0 [ | Important! This commands checks to see if there are any visitors on the same patch as the mugger. If there is at least one visitor on the patch, then any code after the square bracket will run. | 
| set victims ( victims + 1 ) | This code will only be executed if there are victims here. It increases
                    the value of the mugger's victimsvariable by 1 unit. This tells
                    us that a mugging has taken place. | 
| if show-crimes = True [ | The last thing we want to do, after a mugging, is (optionally) to show
                    where crimes have taken place. This command checks to see if 
                    the show-crimesswitch is set to 'on'. | 
| ask patch-here [ | Ask the patch where the mugging has just taken place ... | 
| set plabel-color black | ... to create a label that has black text ... | 
| set plabel "C" | ... and shows the letter 'c' (as in 'crime'). | 
| ]] | Closing braces for the if show-crimes = Trueandask patch-herecommands. | 
| ] | This closing bracket closes the  count visitors-here > 0statement above. | 
| end | Finish the move-and-mugprocedure. | 
go' procedure after the visitors have moved:
            
                  ask muggers [
                    move-and-mug
                  ]
             
            
            
            
                plot ( sum [ victims ] of muggers ) / ( ticks + 1)
            
            (note: ticks+1 is used to prevent problems with dividing by zero
            when the model starts).
            
            When you have finished, your model should look something similar to the one below. There is quite a lot to take in from this practical. Before you finish, have a go at the activity below. It will help you to understand how the behaviour of the agents really works.
 
        
        
         
            
            Change the behaviour of the mugger agents so that, instead of walking randomly around the festival site they move between the two stages.
Hints:
;' character) to hide the old 
                move-and-mug code. This way, you can revert to the old behaviour if
                you want to by commenting-out your new code, and uncommenting the old stuff.