![]() There are some cool things you can only do in NetLogo.Īnything on a line of code after two semicolons (" ") will be ignored by NetLogo but visible to you. Something you just thought of and wanted to try.Create a new breed of ammo boxes that your agent needs to pick up to get more paintballs.Limit the number of paintballs (hint: use a new data box widget to keep track of and display this information).If the player touches a hazard, the player dies Create a new breed of hazards that the player needs to avoid.Use the score widget to keep track of your “number of hits”.Modify the appearance of your agents – try size, shape, and color.This is a really important tip - if you make a habit of this, you will learn programming much faster. Try it the other way and try to understand what happens. Be sure you know how the code works: anyplace you find yourself wondering "Why can't it be this way instead of the way it is here?", you should.You can download a working version of this project here. You should be able to aim and shoot paintballs at turtles (or targets) and if you hit one, the turtles should change to the color of the paintball.It should do all of the things it used to do - be sure you didn't accidentally 'break' anything.You should be sure that your code does all of these things: You can try moving the "die" command around to see what happens and get a feel for how this works. If they exist, they are told to turn the color of "myself" (the paintball that made the ask). (This is because there isn't a "kill" commandįirst, the paintball looks for any targets it has hit. In NetLogo, it is necessary to look at the collision from the point of view of the paintball, not the target. Add in a "delete agent." block from the "Agents" drawer and plug a "collidee" block in so the collidee will be deleted on collision. ![]() ![]() The "collidee" block can be found in the "Detection" drawer - it corresponds to the agent which hit the Turtle.Into that block, put in blocks to set the Turtle's color to the color of the "collidee".do." block from the "Detection" drawer to the Turtle page and choose "paintball" from the pop-up menu. Write code so that, when a turtle is hit by a paintball, the paintball disappears and the turtle gets 'painted all over'. Part 6: Program the Collision between Paintball and Turtle If this does not work correctly in SLN, check your code in the "paintball" tab - especially all the "if." blocks and the "= 15.Paintballs should disappear when they reach the edge of spaceland.Note that you may need to slow the simulation down to catch the paintball moving. If this does not work correctly in NetLogo, check the button settings and the "toShoot" code.If this does not work correctly in SLN, check your code in the "paintball" tab.Pressing the "S" key should shoot a single paintball in the direction you're facing.If this does not work correctly in NetLogo, check the button settings and the "toForward" etc code.If this does not work correctly in SLN, check your code in the "player" tab.You should be able to move the player around spaceland with the A, D, W and X keys.Note that, in NetLogo, you write code for specific agents by putting it inside an "ask." block rather than in the agent's tab as you do in SLN.īe sure that your code can do all of these things (you should learn to push it hard and try to "break" it. You can change this by clicking the "settings" button at the upper right of the controls in NetLogo. Spaceland in NetLogo extends from -16 to 16 in the x direction and -16 to 16 in the y direction with 0,0 in the center. comparison blocks (>, 48 or x > 49 instead of x = 50.Demonstrate how one agent can create another.“ blocks work in the context of keyboard controls Use conditional blocks in the context of keyboard controls.In this set of exercises, you will program more complex behavior and interactions.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |