The castle isn't randomly generated, it's just very confusing. If you need help, you can look up a walkthrough for it.