ID:1154429
 
(See the best response by DarkCampainger.)
Code:
        proc
aiPatrol()
var/area/currentArea=src.loc.loc
var/list/areaTurfs = new/list()
for(var/turf/T in oview(1))
if(T.loc==currentArea)
areaTurfs+=T
step_to(src,pick(areaTurfs))
sleep(5)
spawn() aiPatrol()


Problem description:
I want my mob to randomly walk around, without ever leaving the area he starts in. However, he moves 6 pixels at a time, and my icon size is 32, so I'm pretty sure that he doesn't go up to the boundaries at all, and if the area is two tiles tall then he ends up only going left or right.

TL;DR: My "patrol area" proc kinda works, but I'm certain there's a better way, I just don't know how :P

Thanks for reading, and thanky in advance for any advice!
You should have a little look at this for an idea http://www.byond.com/developer/DarkCampainger/MapPaths
Also you'd want to use a while loop instead of recursively callin aiPatrol() each 5 ticks.
I did not know about MapPaths! That is very cool, but not quite what I want for this proc. I want the mob to move -randomly-, but only within the confines of an area. I'm sure I'll use MapPaths some time for another mob with a different purpose.

Also, the reason I chose not to use while(1) was that at some point (once the proc is further developed) a lot of conditions will trigger it to break out and start other procs instead.

You can still do all that whith a while loop without even having to break the procedure.
Take a look at my post here.
Best response
The issue you're having is that your taking a single step, and then on the next iteration, choosing a brand new destination. So your AI is never walking to the same place long enough to really get anywhere.

To fix this, you need to store the destination and step_to() it each iteration until you reach it, then pick a new one:
mob
ai
var
turf/patrolDest
proc
aiPatrol()
// If the destination isn't set
if(!patrolDest)
// Find a new destination
var/area/currentArea=src.loc.loc
var/list/areaTurfs = new/list()
for(var/turf/T in oview(4, src))
if(T.loc==currentArea)
areaTurfs+=T
patrolDest = pick(areaTurfs)

// Step to our current destination
step_to(src,patrolDest)

// Check if we've reached our destination
if(bounds_dist(src,patrolDest) < 0)
// null-out patrolDest so we pick a new one next iteration
patrolDest = null

sleep(1)
spawn() aiPatrol()


Because you're using pixel movement, I also lowered the sleep() to one tick so it actually moves smoothly.