cache occupied spaces for optimization, and fixed a 'off-by-one' error in snake.validPosition()