Skittles Skittles -4 years ago 76
Python Question

Possible To Run Pymunk Simulation Without Screen (as in without actually seeing it)?

The question I have is, is it possible to run a Pymunk simulation without having the screen to visualize it pop up?

I'm working on a research project that involves Pymunk and Pygame. The goal is to develop an agent that can infer certain properties about physics simulations involving objects and agents within the Pymunk space.

Part of the project requires a comparison of many different simulations and the fact that a screen pops up so I can view each simulation causes the problem to take too much time (as I have to view each sim before being able to collect the data from it).

I'd like to basically run each sim in the background as fast as possible to just collect the physical data. There is no need for me to actually visualize the simulations at certain points.

Let me know if I've been clear enough or this is a duplicate. Though, I searched for an answer here, I have not found one.

Answer Source

Pymunk itself doesn't depend on any visualization. You move the simulation forward with the space.step method, and you can call it as many times as you want, for example 1000 times with a dt of 0.1 to move the simulation forward 100 units (seconds).

If you want to see something you have the option to read out the state and draw it at that time.

The pygame integration provided with pymunk is just for those that want an quick and easy way to get something on screen. If you don't want anything drawn you absolutely not need to use it.

Just be aware that it is not the same to call space.step 100 times with a dt of 0.01 and calling it with a dt of 1 (the later will give a much less accurate simulation)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download