The task of making the croc aware of what's a "pit" where it will be stuck is almost impossible, as there's no way of saying "this is the level" and "this is a pit", all the code can find is two chunks of tiles from which you can pass from one to the other but not the other way around.