Python:繪制一個2d網格並允許細胞着色

[英]Python: Draw a 2d grid and allow coloring of cells


I want to simulate the game of life problem using python. I want to draw a grid and be able to color its cells as the simulation progresses. How do I do that in Python?

我想用python模擬生活游戲的問題。我想畫一個網格,並能夠在模擬過程中為其單元着色。我怎么用Python做到這一點?

5 个解决方案

#1


8  

You can use pygame to do that.

你可以使用pygame來做到這一點。

To display the state of your simulation, you should create an 8 bit surface with a palette, and access it with the pygame.surfarray module.

要顯示模擬的狀態,您應該使用調色板創建一個8位曲面,並使用pygame.surfarray模塊訪問它。

#2


4  

Take a look at PyGame too.

看看PyGame吧。

#3


2  

I suggest Gloss, it's like PyGame except hardware accelerated. It also provides many other game-programming goodies.

我建議使用Gloss,它就像PyGame,除了硬件加速。它還提供許多其他游戲編程的好東西。

#4


1  

I suggest taking a look at the Python Imaging Library (PIL) documentation

我建議看一下Python Imaging Library(PIL)文檔

#5


1  

I know this is an old post, but in the name of building the perfect QA site, I would suggest matplotlib.

我知道這是一個老帖子,但是在建立完美QA網站的名義下,我建議使用matplotlib。

As of this writing, it looks like matplotlib development is getting more attention than pygame development.

在撰寫本文時,看起來matplotlib開發比pygame開發更受關注。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2010/02/15/729cab50d8f1fedbd1fa631df8441001.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com