First, I haven’t posted any code in this topic because I am trying to understand the conceptual issues.
Second, I am working on Harrowland. My assumptions are 1) the Simple CPU is set to be approximately equal to whatever character I use. 2) the Simple CPU is set to run a simple, not terribly efficient set of loops 3) the problem is designed to test for the ability to write a more efficient loop than the Simple CPU is using.
Third) I have come close to winning, but have not won.
Fourth) I think the solution is to sort the enemies to first ignore the yaks, second attack the throwers, third reduce the remaining sub-enemies and finally to attack the Hero.
I only know the type of “sand-yak” and “archer”. I don’t know the type of the other sub-enemies or the hero.
I am only using “loop” and “while”. I don’t know if I missed a lesson on “for” loops or if they are being reserved for later lessons. I think that the “for” loop would be helpful here, but I could be wrong.
The best solution that I can imagine, but I don’t know how to execute, is to sort the Hero and the sand-yaks out of “enemies = self.findEnemies()” and create a second array of the remaining sub-enemies. Once, I had cycled through the second array, I could attack the Hero.
I have tried to simulate that tactic with successive loops. I am not having very much luck. Assuming that the remarks above indicate that I understand the problem, I have some specific questions.
- What are the types of the enemies in the problem and how can I identify them myself?
- Should I be using “for” statements to solve the problem, and where do I find the information on them?
- Is it possible to implement nested “loop” statements efficiently?
- Is somebody willing to discuss how “while” loops end?
Thank you very much,