mapa17 / Kaleidoscope

An infinit number of worlds
MIT License
0 stars 0 forks source link

Multiprocessing of agent function #4

Closed mapa17 closed 6 years ago

mapa17 commented 6 years ago

Use the Pool function the multiprocessing library in order to run multiple process on the data

from multiprocessing import Pool

Maybe use the map function and pass tuples that contain the source world buffer, a target world buffer, and a single line/column that should be processed by a process.

Because they write to different parts of the world target buffer, i don't think the processes need to be coordinated.

mapa17 commented 6 years ago

A lot of added complexity for very little.

The bottleneck is the drawing onto the pygame surface.

Well maybe if the agent code gets very complicated than the multi processing has a bigger impact ...

mapa17 commented 6 years ago

A new plan!

Idea

So the idea is to make the plotting part a separate job that will be receiving the matrix for plotting through a queue.

While the plotter is doing its thing, the rest of the program continues with the world.cycle()

So there would be two things running in parallel

The world.cycle() and the visualization.update()

In world.cycle() we still have the serial part of calling the environment() function, than we execute the workers and afterwards apply the boundary_policy() function, ending with a push into the visualization.update() queue.

Questions