示例#1
0
 def __init__(self, gameDef, levelDef, observationType=OBSERVATION_LOCAL, visualize=False, actionset=BASEDIRS, **kwargs):
     game = _createVGDLGame( gameDef, levelDef )
     StateObsHandler.__init__(self, game, **kwargs)
     self._actionset = actionset
     self.visualize = visualize
     self._initstate = self.getState()
     # 
     # Total output dimensions are:
     #   #object_types * ( #neighbours + center )
     #
     # Note that _obstypes is an array of arrays for object types and their positions, e.g.
     # {
     #  'wall': [(0, 0), (1, 0), (2, 0), (3, 0), (4, 0), (5, 0)], 
     #  'goal': [(4, 1)]
     # }
     self.observationType=observationType
     if observationType == OBSERVATION_LOCAL:
         # Array of grid indices around the agent
         ns = self._stateNeighbors(self._initstate)
         self.outdim = [(len(ns) + 1) * len(self._obstypes), 1]
     else:
         self.nsAllCells = []
         self.outdim = [game.height, game.width]
         for y in range(0, game.height):
             for x in range(0, game.width):
                 self.nsAllCells.append( (x, y) )
     self._postInitReset()                
示例#2
0
 def __init__(self, game, actionset=BASEDIRS, **kwargs):
     StateObsHandler.__init__(self, game, **kwargs)
     self._actionset = actionset
     self._initstate = self.getState()
     ns = self._stateNeighbors(self._initstate)
     self.outdim = (len(ns) + 1) * len(self._obstypes)
     self.reset()
示例#3
0
 def __init__(self, game, actionset=BASEDIRS, **kwargs):
     StateObsHandler.__init__(self, game, **kwargs)
     self._actionset = actionset
     self._initstate = self.getState()
     ns = self._stateNeighbors(self._initstate)
     self.outdim = (len(ns) + 1) * len(self._obstypes)
     self.reset()                
示例#4
0
 def setState(self, state):
     if self.visualize and self._avatar is not None:
         self._avatar._clear(self._game.screen, self._game.background)
     StateObsHandler.setState(self, state)
     self._game._clearAll(self.visualize)
     assert len(self._game.kill_list) == 0
示例#5
0
 def setState(self, state):
     if self.visualize and self._avatar is not None:
         self._avatar._clear(self._game.screen, self._game.background)        
     StateObsHandler.setState(self, state)        
     self._game._clearAll(self.visualize)  
     assert len(self._game.kill_list) ==0