getTile needs to check if (map && map[y]) since the 2d array could be sparse.  the dereference of map[y][x] could fail in some cases. this was working after I added support for custom size mazes in both maze and karel.  see normalize function down below.  It may not be absolutely necessary given the levels right now, but it seems like a safe check to be consistent.