def eval_fitness(self, chromosome):
<EOL>sx, sy = self.translator.translate_chromosome(chromosome)<EOL>penalty = <NUM_LIT:0><EOL>if sx >= self.w:<EOL><INDENT>penalty += self.w * self.h<EOL><DEDENT>if sy >= self.h:<EOL><INDENT>penalty += self.w * self.h<EOL><DEDENT>if penalty > <NUM_LIT:0>:<EOL><INDENT>self.fitness_cache[chromosome.dna] = -penalty<EOL>return -penalty<EOL><DEDENT>crops_watered = <NUM_LIT:0><EOL>row_start_idx = max(<NUM_LIT:0>, sy - self.r)<EOL>row_end_idx = min(sy + self.r + <NUM_LIT:1>, self.h)<EOL>col_start_idx = max(<NUM_LIT:0>, sx - self.r)<EOL>col_end_idx = min(sx + self.r + <NUM_LIT:1>, self.w)<EOL>for y, row in enumerate(self.maplist[row_start_idx:row_end_idx], row_start_idx):<EOL><INDENT>for x, cell in enumerate(row[col_start_idx:col_end_idx], col_start_idx):<EOL><INDENT>if cell == '<STR_LIT:x>' and sprinkler_reaches_cell(x, y, sx, sy, self.r):<EOL><INDENT>crops_watered += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>if self.maplist[sy][sx] == '<STR_LIT:x>':<EOL><INDENT>crops_watered -= <NUM_LIT:1><EOL><DEDENT>self.fitness_cache[chromosome.dna] = crops_watered<EOL>return crops_watered<EOL>
Return the number of plants reached by the sprinkler.

Returns a large penalty for sprinkler locations outside the map.