Slime moulds use a form of spatial "memory" to navigate, despite not having a brain, a study has found.