1

I recently learned Python and succesfully programmed Conway's game of life using numpy arrays. My problem is that I can't plot them. I can plot one array, but I don't know how to update the plot in the current matplotlib window as much as I want.

A funtion to calculate the next generation (takes a numpy array as argument and returns one too) and the start grid (numpy array) are given. I'm using Python 3.9.

I can't find a simple solution with a while loop that doesn't open a new window for every iteration. It shouldn't be that hard. Could anyone help me?

I have already found: Matplotlib: Animate 2D Array, but that doesn't work.

The_spider
  • 1,202
  • 1
  • 8
  • 18
snek
  • 11
  • 1
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Apr 20 '23 at 23:52
  • 1
    It's unspecific. See [ask]. Research more, try to implement a prototype and post a [mre] and debugging details. Anyway, see [this question](https://stackoverflow.com/questions/74990097/how-can-i-use-scipy-integrate-solve-ivp-to-solve-an-ode-in-an-interactive-simu) and [this question](https://stackoverflow.com/questions/30154888/matplotlib-animation-of-a-step). – relent95 Apr 23 '23 at 10:15
  • I was having trouble accomplishing a similar task, so instead of displaying each frame as it's calculated (ie. 'realtime'), I precompute and store them. Then I use an ipympl widget to scroll through the buffer like a video. I'll post my code if that sounds helpful. – Adam Conrad May 04 '23 at 17:27
  • Do you really need to use matplotlib for this? I think that pygame is a lot better suited for this problem. – The_spider Aug 27 '23 at 16:02

0 Answers0