From: <ve...@us...> - 2014-07-21 17:54:14
|
Revision: 7278 http://sourceforge.net/p/freeorion/code/7278 Author: vezzra Date: 2014-07-21 17:54:07 +0000 (Mon, 21 Jul 2014) Log Message: ----------- Universe generation scripts: simplification of AdjacencyGrid.too_close_to_other_positions suggested by Cjkjvfnby Modified Paths: -------------- trunk/FreeOrion/default/universe_generation/galaxy.py Modified: trunk/FreeOrion/default/universe_generation/galaxy.py =================================================================== --- trunk/FreeOrion/default/universe_generation/galaxy.py 2014-07-21 14:15:34 UTC (rev 7277) +++ trunk/FreeOrion/default/universe_generation/galaxy.py 2014-07-21 17:54:07 UTC (rev 7278) @@ -34,18 +34,8 @@ upper_left_y = max(0, cell_y - 1) lower_right_x = min(self.width - 1, cell_x + 1) lower_right_y = min(self.width - 1, cell_y + 1) - too_close = False - for index_x in range(upper_left_x, lower_right_x + 1): - for index_y in range(upper_left_y, lower_right_y + 1): - for pos in self.grid[index_x][index_y]: - if util.distance(pos.x, pos.y, x, y) < self.min_dist: - too_close = True - break - if too_close: - break - if too_close: - break - return too_close + return any(util.distance(pos.x, pos.y, x, y) < self.min_dist for cx in range(upper_left_x, lower_right_x + 1) + for cy in range(upper_left_y, lower_right_y + 1) for pos in self.grid[cx][cy]) def test_galaxy_calc_positions(positions, size, width): |