Вы находитесь на странице: 1из 6

Agent assignment solution

Produced by student : Ali Jamil

We have this agent

We want to reach our goals which is cleaning every ground piece on


the place according to the specified positions
As a begin we have these facts and actions :

Actions:
change_direction
move_one_step
suck
In(x,y) agent is at (x,y)
Dirt(x,y) there is a dirt at (x,y)

Our work strategy is according to the above graph .


With the movment from one node to other were each node is a room

(1) moving to the first room


as a start movement for the agent to clean the first
room , start cleaning by moving line by line and
vertically and as follows :
the logic steps ( program ) for the first room :

In(x,y) agent is at (x,y)


For (i=1 ; i<= length of the room ; i++)

y=i;

move_one_step (X,Y+1)
if ( in(x,y) are some thing prevent the agent from go on ) then
{
change_direction (x+1, y)
move_one_step (X,Y+1)
then return to the specific road by :
change_direction (x-1, y)
move_one_step (X,Y+1)

if ( dirt (x,y) )
{
suck(x,y)
}
Else Continue moving

In(x,y) " is the current agent position at the end of the room , so know the agent
have to change its direction to the left by 1 position

move_one_step (X+1,Y)
know the agent will rescan the room vertically and performing the same steps
but in descending order and as follows :

In(x,y) agent is at (x,y)


For (i= length of the room ; i<= 1 ; i - - )

y=i;

move_one_step (X,Y-1)
if ( in(x,y) are something prevent the agent from go on ) then
{
change_direction (x+1, y)
move_one_step (X,Y-1)
then return to the specific road by :
change_direction (x-1, y)
move_one_step (X,Y-1)

if ( dirt (x,y) )
{
suck(x,y)
}
Else Continue moving

After iterate the above two steps according to the room length and width the room will
be cleaned perfectly by the movement of the agent , and the first goal has been
achieved

(2) Cleaning the second room


The agent hav e finished cleaning the first room ,
so , its headed to the next room to clean it
following the same methodology that have been
approved in the first step

When the agent arrived to the door of the room ,


it will be automatically start scaning for dirt places
but we will change the scan method , accounting
on the horizontally fashion instead of vertically
fashion . same result but may be different time to
accomplish the goal
And the logical program for it as follows :

In(x,y) agent is at (x,y)


3

For (i=1 ; i<= width of the room ; i++)

x=i;

move_one_step (X+1,Y)
if ( in(x,y) are something prevent the agent from go on ) then
{
change_direction (x, y+1)
move_one_step (X+1,Y)
then return to the specific road by :
change_direction (x, y-1)
move_one_step (X+1,Y)

if ( dirt (x,y) )
{
suck(x,y)
}
Else Continue

In(x,y) " is the current agent position at the end corner , so know the agent have to
change its direction to the down by 1 position

move_one_step (X,Y-1 )
and moving in reverse order trying to reach the other position of the room , so initially
we will perform the following steps :
For ( I = width of the room ; i<=1 ; i- - )

x= i;

move_one_step (X-1,Y)
if ( in(x,y) are something prevent the agent from go on ) then
{
change_direction (x, y+1)
move_one_step (X-1,Y)
then return to the specific road by :
change_direction (x, y-1)
move_one_step (X-1,Y) }
if ( dirt (x,y ) )
{
suck(x,y)
}
Else Continue
4

The second room has been cleaned to , the second goal have been achieved .
The cleaning of the other rooms will follow the same methods for cleaning the rooms

The same steps , moving from the start of each room, . perform vertically or
horizontally scan then clean every position that you find any dirt in it .

This type of agent follow the sequential way in scanning . scan every place and postion
in the rooms to cleaning
And adaptation to the agent is to add predictability . predicating the place of
dirt . and go for it . this will minimize the massive scan time and speed up the cleaning
process and time required by it .

Вам также может понравиться