I got the same error Microsoft SharePoint Server 2013 encountered an error during setup,
In my case, the root cause was because of using only one processor core for my Hyper - V to install SharePoint that should be more than one so I followed the mentioned steps here to increase it , Hope this help you.