• No results found

Adding Sensing Capabilities to Turtle Agents in NetLogo Exercise .1:

In document Download free books at  (sider 81-87)

Exploration and production in Norway

5.3 Adding Sensing Capabilities to Turtle Agents in NetLogo Exercise .1:

Try out the following models in NetLogo using the links below. These models implement basic sensing capabilities in turtle agents. These models (apart from the Wall Following Example model) have been updated from the ones provided in the Code Examples of NetLogo’s Models Library by adding further sliders in the Interface to extend the simulation options as detailed below.

The Look Ahead Example 2 model simulates a basic sense of vision for each turtle agent by using the patch-ahead command. The model has been modified to add the number-of-turtles slider in the Interface to allow the user to control how many turtles are created at the start of the simulation.

Look Ahead Example 2

In NetLogo Model’s Library: Code Examples > Look Ahead Example.

See modified code at:

http://files.bookboon.com/ai/Look-Ahead-Example-2.html

Download free ebooks at bookboon.com 82

Figure 5.3.1.1 Screenshot of the Interface for the Look Ahead Example 2 model after the setupbutton has been pressed followed by the pen-down and go buttons.

The Wall Following Example model is the same as the one in NetLogo’s Models Library. It demonstrates wall following behaviour by using the patch-right-and-ahead command to simulate the sense of touch via proximity detection.

Wall Following Example

In NetLogo Model’s Library: Code Examples > Wall Following Example http://ccl.northwestern.edu/netlogo/models/WallFollowingExample

Download free ebooks at bookboon.com 83

Figure 5.3.1.2 Screenshot of the Interface for the Wall Following model after the setupbutton has been pressed followed by the pen-down and go buttons.

The Line of Sight Example 2 model is a slight modification of the model provided in NetLogo’s Models Library – instead of 6 walker turtle agents being created, there are 20. The model implements a sense of vision by working out what each walker agent would “see” in its line of sight. Sometimes due to the immediate terrain, this line of sight may be restricted because of nearby hill obscuring its vision. Other times, the line of sight will be longer.



Please click the advert

Download free ebooks at bookboon.com 84

Line of Sight Example 2

In NetLogo Model’s Library: Code Examples > Line of Sight Example.

See modified code at:

http://files.bookboon.com/ai/Line-of-Sight-Example-2.html

Figure 5.3.1.3 Screenshot of the Interface for the Line of Sight Example 2 model after the setupbutton has been pressed followed by the go button.

The Vision Cone Example 2 model is a slight modification of the model provided in NetLogo’s Models Library. Two sliders have been added to the Interface – number-of-standers and number-of-wanderers – to control the number of grey stander agents that don’t move, and the number of red wanderer agents that move around sensing what is in the environment. The model implements the wanderer’s sense of vision using NetLogo’s in-cone command.

Vision Cone Example 2

In NetLogo Model’s Library: Code Examples > Vision Cone Example.

See modified code at:

http://files.bookboon.com/ai/Vision-Cone-Example-2.html

Download free ebooks at bookboon.com 85

Figure 5.3.1.4 Screenshot of the Interface for the Vision Cone Example 2 model after the setupbutton has been pressed followed by the go(forever)button.

The Hill Climbing Example 2 model simulates turtle agents with an ability to sense what is uphill in the terrain using NetLogo uphill command. The model is the same as provided in NetLogo’s Models Library, except for the following added to the Interface: a go once button so that the user can control the movement of the turtle agents one step at a time per tick; and the number-of-turtles slider that controls the number of turtles created in the environment. Since turtles are created at random patches using the n-of and sprout commands, increasing the value of this slider to greater than or equal to the number of patches, followed by pressing the go button will result in all the possible paths the turtle agents can take (as dictated by its hill-climbing behaviour), being drawn in the environment, as shown in the image below. This results in an almost 3D effect where the paths along the highest points of the ridge-lines are clearly shown.

Hill Climbing Example 2

In NetLogo Model’s Library: Code Examples > Hill Climbing Example.

See modified code at:

http://files.bookboon.com/ai/Hill-Climbing-Example-2.html

Download free ebooks at bookboon.com 86

Figure 5.3.1.5 Screenshot of the Interface for the Hill Climbing Example 2 model after the setupbutton has been pressed followed by the go button. The case shown occurs when the

value in the number-of-turtles slider exceeds the maximum number of patches in the environment.

Please click the advert

Download free ebooks at bookboon.com 87

Analyse each of the models to see how effective they are for the turtle agents at providing a means for sensing what is happening in the environment. Have a go at further extending the models by adding further capabilities to enhance the turtle agent’s senses. How difficult would it be to have a turtle agent have more than once sense? That is, what are the problems at coordinating the actions of the agents in response to sensory events happening on multiple input streams?

Exercise 5.3.2:

When the pen-down button is pressed in the Look Ahead Example 2 model, the paths quickly fill up the rest of the environment apart from the blue patches. Make use of this behaviour to design a model that simulates an autonomous vacuum cleaner robot that cleans the floor of a room (like the one depicted in Section 2.2 of the Artificial Intelligence – Agents and Environments book). Try adding one or more further behaviours so that the simulated robot covers the environment in a different manner to the method used for the Look Ahead Example 2 model. Extend the model so that the user can add further obstacles into the environment.

5.4 Performing tasks reactively without cognition

In document Download free books at  (sider 81-87)