javascript magic: var directions = [-1,0,1].reduce(function(l,a,i,arr){l.push(arr.map(function(b){return [a,b];}));return l},[]);
javascript magic: var directions = [-1,0,1].reduce(function(l,a,i,arr){l.push(arr.map(function(b){return [a,b];}));return l},[]);