A better explanation: every tick, before the AI/movement code, every actor updates map[actor.x][actor.y].contents to include itself, "contents" being a list of everything in the tile. Then, in the FoV code, the actor goes through however many tiles are a certain distance away from it, and draws its list of potential targets from the tile's contents.
The thing I like about this is- well, it's much faster than the original code, but other than that- it feels more like a 'sense' than the old code did. Before, I was having every actor look at every other actor and compare their positions to every tile in its field of view. The new code doesn't access the variables of another actor at all, let alone the ones that the active one shouldn't know about. It's a purely aesthetic preference, since it doesn't really affect much, but I like it.
The way I determine what parts of the map they're looking at is simple. It ends up with squares, rather than circles, but I can live with that for now.
for x in range(self.look_diam):
for y in range(self.look_diam):
sx = self.x+(x-int(self.look_diam/2)) #"Translate" the look_diam so that its center is on the actor's x position.
sy = self.y+(y-int(self.look_diam/2)) #Do the same for y.
.
if (SCREEN_W-1) > sx > 0:
if (SCREEN_H-1) > sy > 0: #This bit keeps the view from wrapping around the screen and causing clairvoyant actors
#Here is where the actual information code goes.
map[sx][sy].explored = True #Mark tiles actors can "see" on the map, so that I can render them differently.
if map[sx][sy].contents:
#This should be a 'for' loop, but I was lazy and tiles never have more than one thing at a time anyway.
self.target_list.append(map[sx][sy].contents[0])