```
In [1]:
```from ipythonblocks import BlockGrid as bg
from IPython.html.widgets import interact, interactive, fixed
from IPython.html import widgets
import random
import numpy as np
%matplotlib inline
import matplotlib.pyplot as plt
from IPython.display import Image

```
```

```
In [2]:
```def array_city(x, p1, p2):
p0 = 1-(p1+p2)
p1 = 1-(p0+p2)
p2 = 1-(p0+p1)
grid = (np.random.choice([0, 1 , 2], size = (x, x), p = [p0, p1, p2]))
return grid

```
In [3]:
```def visualize(grid):
g = bg(grid.shape[0], grid.shape[0])
for row in range(g.height):
for col in range(g.width):
block = g[row,col]
if grid[row,col] == 0:
block.blue = 1000
block.red = 1000
block.green = 1000
if grid[row,col] == 1:
block.blue = 2000
block.red = 0
block.green = 0
if grid[row,col] == 2:
block.red = 2000
block.green = 0
block.blue = 0
return g

```
In [4]:
```def visualize_big(grid):
g = bg(grid.shape[0], grid.shape[0],block_size = 5)
for row in range(g.height):
for col in range(g.width):
block = g[row,col]
if grid[row,col] == 0:
block.blue = 1000
block.red = 1000
block.green = 1000
if grid[row,col] == 1:
block.blue = 2000
block.red = 0
block.green = 0
if grid[row,col] == 2:
block.red = 2000
block.green = 0
block.blue = 0
return g

```
In [5]:
```g = array_city(90,0.1,0.1)
visualize_big(g)

```
Out[5]:
```

Example of low amount of empty squares

```
In [7]:
```g = array_city(90,0.45,0.45)
visualize_big(g)

```
Out[7]:
```