简体   繁体   English

Python:绘制2d网格并允许细胞着色

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

I want to simulate the game of life problem using python. 我想用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做到这一点?

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模块访问它。

看看PyGame吧

I suggest Gloss , it's like PyGame except hardware accelerated. 我建议使用Gloss ,它就像PyGame,除了硬件加速。 It also provides many other game-programming goodies. 它还提供许多其他游戏编程的好东西。

我建议看一下Python Imaging Library(PIL) 文档

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开发更受关注。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM