Interacting with complex and dynamic environments challenges the brain’s ability to adapt to change. This key ability known as cognitive flexibility involves learning the structure of the environment, switching attention between features, dimensions …