function action = CS6380_Assgn1_reflex_agent(percept)
% CS6380_Assgn1_reflex_agent - cleaning reflex agent function
%   if dirt present, action is to clean
%   else move in random (8 neigbor) direction
% On input:
%     percept (int): 0: no dirt present; 1 dirt present
% On output:
%     action (int): robot action
%       0: no action
%       1: clean
%       2: move right
%       3: move up & right
%       4: move up
%       5: move up & left
%       6: move left
%       7: move down & left
%       8: move down
%       9: move down & right
% Call:
%     a = CS6320_Assgn1_reflex_agent(0)
% Author:
%     T. Henderson
%     UU
%     Summer 2014
%

CLEAN = 1;
MOVES = [2:9];

if percept==1    % dirt present
    action = CLEAN;
else
    index = floor(8*rand) + 1;
    action = MOVES(index);
end
