Advertisement
Guest User

Untitled

a guest
May 24th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. # Create a firewall
  2.  
  3. firewall_x = int( grid_width / 3 )
  4.  
  5. for row in grid:
  6. row[ firewall_x ] = 3
  7.  
  8. # Now leave some holes
  9.  
  10. porosity = 0.2
  11. num_holes = int( grid_height * porosity )
  12. hole_count = 0
  13.  
  14. while hole_count < num_holes:
  15. hole_y = random.randint( 0 , grid_height - 1 )
  16. if grid[ hole_y ][ firewall_x ] == 3:
  17. grid[ hole_y ][ firewall_x ] = 1
  18. hole_count += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement