Stop walking into walls!
JavaScript (ES6), 192 163 bytes

a=&gt;b=&gt;a[(a[4]=0)+--b]?(A=(c,d)=&gt;c==b|(e=a[c])-(f=a[d])|!e?(a[c-b?(e?e&lt;f:new Date&amp;1)?c:d:4]=2,a):A(+g[c],+h[d]))(+(g="3016X2785")[b],+(h="1250X8367")[b]):(a[b]=2,a)


Notes

This function uses a special input format. The first input is an array of integers (0 for floor, 1 for wall and 2 for player) representing the map. The second input is the (flipped) direction: 1 is north-west, 2 is north, 3 is north-east, 4 is west etc. The inputs should be given through currying syntax (Z(a)(b)).

Test cases

The maps and directions have been modified to suit my input format.



Z=
a=&gt;b=&gt;a[(a[4]=0)+--b]?(A=(c,d)=&gt;c==b|(e=a[c])-(f=a[d])|!e?(a[c-b?(e?e&lt;f:new Date&amp;1)?c:d:4]=2,a):A(+g[c],+h[d]))(+(g="3016X2785")[b],+(h="1250X8367")[b]):(a[b]=2,a)

testcases = [
    [[1,0,0,0,2,1,1,0,1], 3],
    [[1,0,0,0,2,1,1,0,1], 9],
    [[1,1,0,1,2,1,0,0,1], 1],
    [[0,0,0,0,2,0,0,0,0], 5],
    [[1,1,1,1,2,1,1,1,1], 2]
]
for (test of testcases) {
    console.log(Z(test[0])(test[1]))
}