Skip to content

Commit

Permalink
use replacement() instead of self.BLANK
Browse files Browse the repository at this point in the history
  • Loading branch information
silverweed committed Feb 17, 2015
1 parent 9e3ae2d commit ff099f0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions boomlevelgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,13 @@ def openBoundaries(self,region):
# At the moment, doesn't take bosses into account.
def securePlayer(self, coords):
(px, py) = coords
replacement = lambda: self.BLANK if random.random() < 0.8 else self.COIN
# check the immediate surroundings and delete enemies
for i in range(max(0, py - 1), min(13, py + 2)):
for j in range(max(0, px - 1), min(15, px + 2)):
if self.grid[i][j] in self.ENEMY:
self.grid[i][j] = self.BLANK
self.grid[i][j] = replacement()

# check if any enemy is too nearby in a direct line (at distance
# <= 4 from a player with no wall in between)
def dangerousUpLeft(enemy, wall):
Expand All @@ -325,7 +327,7 @@ def dangerousDownRight(enemy, wall):
if enemy == None: return False
if wall == None: return True
return enemy < wall
replacement = lambda: self.BLANK if random.random() < 0.8 else self.COIN

# Up
nearestEnemyY = None
nearestWallY = None
Expand Down

0 comments on commit ff099f0

Please sign in to comment.