Finally came back to this problem.

As for problem 24 with the immune system, the hardest part about this problem is making sure you read the description correctly. It took me a couple of attempts with the test cases before getting all the rules nailed down.

I went with 3 classes in this problem:

  • Map: containing a list of open tiles in the map and a list of units, this also contains the logic for playing a game (first part of the problem) and playing multiple games with different attack values for the elves (second part of the problem);
  • Unit: defining the elves and goblins, this also contains the logic for how a unit plays his turn, attacks, moves, finds the nearest opponent, etc;
  • Position: defining a position on the grid, this is usually not needed as it may be replaced by a simple tuple, but was useful as I added some fonctions to return adjacent positions and compare them directly.