I am going through the learning section about programming a bot and have questions about the final example code presented:
For lines 3-9 I need some clarification about what would actually happen here.
a) In line 3 is there a sequence it goes through when you say "CARDINALS"? (e.g., NORTH, SOUTH, EAST, WEST)?
b) Let's say you are on location (1,1) and it finds that the neighbor location SOUTH is !=myID and neighbor_site.strenght < site.strength, does it move the piece SOUTH to (1, 2) during that run of the for loop? If so, does it continue with the sequence in the for loop even though that space is now at a strength of 0? Now that it is on (1,2), when the loop below gets to (1,2) does it see that new piece there now?
1 def move(location):
2 site = gameMap.getSite(location)
3 for d in CARDINALS:
4 neighbour_site = gameMap.getSite(location, d)
5 if neighbour_site.owner != myID and neighbour_site.strength < site.strength:
6 return Move(location, d)
7 if site.strength < site.production * 5:
8 return Move(location, STILL)
9 return Move(location, NORTH if random.random() > 0.5 else WEST)
11 while True:
12 moves = 
13 gameMap = getFrame()
14 for y in range(gameMap.height):
15 for x in range(gameMap.width):
16 location = Location(x,y)
17 if gameMap.getSite(location).owner == myID: