Automatic Generation of Programs for Crawling and Walking