Robot learns to build, adapt using Lego models