function obs = get_env_N(curr_state,action,N)

% The B matrix or $P(s_{t}\mid s_{t-1}, u_{t-1})$

%grid_locations=[0, 0; 0, 1; 0, 2; 1, 0; 1, 1; 1, 2; 2, 0; 2, 1;2, 2];
%grid_locations=grid_locations+1;


%actions = ["UP", "DOWN", "LEFT", "RIGHT", "STAY"]

%def create_B_matrix():
  %B = zeros(size(grid_locations,1), size(grid_locations,1), length(actions));

  % for i=1:length(actions)
  % 
  %   for j=1:size(grid_locations,1)
  % 
  %     %y, x = grid_location
  %      y=grid_locations(j,1);
  %      x=grid_locations(j,2);
  %      curr_state=grid_locations(:,1)==y&grid_locations(:,2)==x;
       y=curr_state(1);
       x=curr_state(2);
       
       
       if action=="UP" 
        next_x = x;
       if y > 1
        next_y = y - 1; 
       else 
        next_y = y; 
       end
       end
       
       if action=="DOWN" 
        next_x = x;
       if y < N
        next_y = y + 1; 
       else 
        next_y = y;
       end
       end
       
       if action == "LEFT" 
        next_y = y;
       if x > 1 
        next_x = x - 1;  
       else 
        next_x = x; 
       end 
       end
       
             
       if action == "RIGHT" 
        next_y = y;
       if x < N
        next_x = x + 1;
       else 
        next_x = x ;
       end 
       end
       
       if action == "STAY"
        next_x = x;
        next_y = y;
        end
     
        
  %     %new_location(i) = [next_y, next_x];
  %     %next_state = grid_locations.index(new_location)
  %     next_state=grid_locations(:,1)==next_y&grid_locations(:,2)==next_x;
  %     %B[next_state, curr_state, action_id] = 1.0
  %     B(next_state,curr_state,i)=1;
  %   end
  % 
  % end
  obs=[next_y,next_x];