資源簡介
2017年美賽B題的程序,效果非常好,完美模擬道路上的車輛行駛以及堵車狀況;
可以調整車流密度,和車輛的大小

代碼片段和文件信息
import?numpy?as?np
import?matplotlib.pyplot?as?plt
import?matplotlib.animation?as?animation
fig?=?plt.figure()
def?f(x?y):
????return?np.sin(x)?+?np.cos(y)
x?=?np.linspace(0?2?*?np.pi?120)
y?=?np.linspace(0?2?*?np.pi?100).reshape(-1?1)
im?=?plt.imshow(f(x?y)?cmap=plt.get_cmap(‘viridis‘)?animated=True)
def?updatefig(*args):
????global?x?y
????x?+=?np.pi?/?15.
????y?+=?np.pi?/?20.
????im.set_array(f(x?y))
????return?im
ani?=?animation.FuncAnimation(fig?updatefig?interval=50?blit=True)
plt.show()
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????533??2017-01-21?17:29??cellular\.idea\cellular.iml
?????文件????????700??2017-01-21?17:29??cellular\.idea\misc.xm
?????文件????????268??2017-01-20?23:42??cellular\.idea\modules.xm
?????文件??????37486??2017-01-24?06:09??cellular\.idea\workspace.xm
?????文件????????545??2017-01-21?00:49??cellular\animition_exm.py
?????文件???????2450??2017-01-21?16:35??cellular\funcs.py
?????文件???????3555??2017-01-21?16:28??cellular\funcs.pyc
?????文件???????3903??2017-01-23?18:21??cellular\main.py
?????文件????????707??2017-01-21?09:11??cellular\point.py
?????文件???????1688??2017-01-21?16:27??cellular\point.pyc
?????文件???????3522??2017-01-21?17:41??cellular\__pycache__\funcs.cpython-35.pyc
?????文件???????1386??2017-01-21?17:41??cellular\__pycache__\point.cpython-35.pyc
?????目錄??????????0??2017-01-24?06:09??cellular\.idea
?????目錄??????????0??2017-01-21?17:41??cellular\__pycache__
?????目錄??????????0??2017-01-23?18:21??cellular
-----------?---------??----------?-----??----
????????????????56743????????????????????15
- 上一篇:Python二級考試試題.zip
- 下一篇:Python爬取教務系統課程表
評論
共有 條評論