Ejemplo n.º 1
0
 def getNextStep(self,state):
     listState=[]
     st=time.time()
     if state.player==SELF_PLAYER:
         tmpPlayer=ENEMS_PLAYER
     else:
         tmpPlayer=SELF_PLAYER
     loc,dirs=self.getMoveCombinationAll(tmpPlayer, state)
  
     for i in range(len(loc)):
         tempLoc=loc[i]
         tempDirs=dirs[i]
         colisionMove=False
         for e in tempLoc:
             if tempLoc.count(e)>1:
                 colisionMove=True
         if colisionMove:
             continue
         cMap=self.getClearMap(state,tmpPlayer)
         for (r,c) in tempLoc:
             cMap[r][c]=tmpPlayer
         s=GameState(cMap, tmpPlayer)
         s.dirs=tempDirs
         listKill=self.preKill(s)
         for (r,c,p) in listKill:
             s.map[r][c]=LAND
         s.reward=(len(self.getAnts(s,SELF_PLAYER)),len(self.getAnts(s, ENEMS_PLAYER)))
         listState.append(s)
     
     return listState
Ejemplo n.º 2
0
 def result(self,state,a):
     [loc,dir]=a
     if state.player==SELF_PLAYER:
         tmpPlayer=ENEMS_PLAYER
     else:
         tmpPlayer=SELF_PLAYER
     cMap=self.getClearMap(state,tmpPlayer)
     for (r,c) in loc:
         cMap[r][c]=tmpPlayer
     s=GameState(cMap, tmpPlayer)
     s.dirs=dir
     s.loc=loc
     self.saveSumDistance(s)
     listKill=self.preKill(s)
   
     for (r,c,p) in listKill:
             s.map[r][c]=LAND
     s.reward=(len(self.getAnts(s,SELF_PLAYER)),len(self.getAnts(s, ENEMS_PLAYER)))
     
     return s