I want to simulate robots looking for food in an unknown 2D environment.
The idea is to make them evolve with genetic algorithms. The robots have some captors to see forward and motors to move. There are some food sources on the surface of the 2D environment.
I plan to use Qt for the graphical simulation using classes QGraphicsScene and QGraphicsView.
My question is : As I’m going to run the simulation hundreds of times (genetic algorithms), I only want to display the last iteration and to hide all the previous ones. Is it possible to use only the QGraphicsScene for that, without the QGraphicsView except for the last iteration? And most important, is it efficient?
A QGraphicsView can only display one scene at a time, using
QGraphicsView::setScene(). It would be perfectly fine to have many QGraphicsScenes, but only showing one of them; in your case, the last iteration.I would say this is an efficient approach unless you have many scenes each with many QGraphicsItems (e.g., thousands), in which case memory might become an issue.