mirror of
https://github.com/apachecn/ailearning.git
synced 2026-04-24 10:34:08 +08:00
2020-10-19 21:08:55
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
In [1]:
|
||||
|
||||
```
|
||||
```py
|
||||
%matplotlib inline
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
@@ -14,7 +14,7 @@ import numpy as np
|
||||
|
||||
In [2]:
|
||||
|
||||
```
|
||||
```py
|
||||
class Forest(object):
|
||||
def __init__(self, size=(150, 150), p_sapling=0.0025, p_lightning=5.e-6, name=None):
|
||||
self.size = size
|
||||
@@ -73,7 +73,7 @@ class Forest(object):
|
||||
|
||||
In [3]:
|
||||
|
||||
```
|
||||
```py
|
||||
forest = Forest()
|
||||
|
||||
```
|
||||
@@ -82,12 +82,12 @@ forest = Forest()
|
||||
|
||||
In [4]:
|
||||
|
||||
```
|
||||
```py
|
||||
print forest.trees
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
[[False False False ..., False False False]
|
||||
[False False False ..., False False False]
|
||||
[False False False ..., False False False]
|
||||
@@ -100,12 +100,12 @@ print forest.trees
|
||||
|
||||
In [5]:
|
||||
|
||||
```
|
||||
```py
|
||||
print forest.forest_fires
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
[[False False False ..., False False False]
|
||||
[False False False ..., False False False]
|
||||
[False False False ..., False False False]
|
||||
@@ -120,7 +120,7 @@ print forest.forest_fires
|
||||
|
||||
In [6]:
|
||||
|
||||
```
|
||||
```py
|
||||
plt.matshow(forest.trees, cmap=plt.cm.Greens)
|
||||
|
||||
plt.show()
|
||||
@@ -195,7 +195,7 @@ QmCC
|
||||
|
||||
In [7]:
|
||||
|
||||
```
|
||||
```py
|
||||
forest.advance_one_step()
|
||||
plt.matshow(forest.trees, cmap=plt.cm.Greens)
|
||||
plt.show()
|
||||
@@ -275,7 +275,7 @@ H+OqGfP4E0uBAAAAAElFTkSuQmCC
|
||||
|
||||
In [8]:
|
||||
|
||||
```
|
||||
```py
|
||||
for i in range(500):
|
||||
forest.advance_one_step()
|
||||
plt.matshow(forest.trees, cmap=plt.cm.Greens)
|
||||
@@ -283,7 +283,7 @@ print forest.tree_fraction
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
```py
|
||||
0.253111111111
|
||||
|
||||
```
|
||||
@@ -487,7 +487,7 @@ umuSMqXPktIjabewndc6Unqk/XkzHIHD4dgYFrGz0OFwLA/OETgcDp8IHA6HTwQOhwM+ETgcDvhE
|
||||
|
||||
In [9]:
|
||||
|
||||
```
|
||||
```py
|
||||
forest = Forest()
|
||||
tree_fractions = []
|
||||
for i in range(5000):
|
||||
|
||||
Reference in New Issue
Block a user