rgsimulator icon indicating copy to clipboard operation
rgsimulator copied to clipboard

Fix player reloading

Open mueslo opened this issue 11 years ago • 2 comments

When you show actions, the rg.game.Player state is modified. Currently, rgsimulator simply reinstantiates the bots (essentially wiping their memory). This is as if the game started on the turn where the actions are shown.

Two things can change when the actions are generated from the Player instance:

  • [...]._robot, i.e. the instantiated Robot instance may change (this should be able to be cached by copy.deepcopy)
  • [...]._module, i.e. the globals, builtins, code, etc of the robot code (this cannot be cached by copy.deepcopy, since not all elements of a module can be deepcopied).

To account for the _module problem, my idea would be to attempt to find out which globals were set by the user and explicitly cache those.

mueslo avatar Aug 14 '14 00:08 mueslo

So the problem is that rgsimulator can't be used for bots which record and use history of previous turns? It could be partially fixed by not reloading bots the first time actions are calculated, so that continuously simulating turns(pressing Return) would work even for history-eware bots. Adding robot caching looks like a great idea. Not sure how to implement global tracking...

mpeterv avatar Aug 14 '14 08:08 mpeterv

Yep, that's it. I actually have the solution you suggested implemented locally, but only because I haven't managed to cache players.

mueslo avatar Aug 14 '14 08:08 mueslo