def reset(self): #print("Resetting") self.stateList=[] self.history=self.maze.mazeString+"|"+"0" self.finished=0 for p in self.pList: p.setInitPos(Cord(self.maze.getInitialX(),self.maze.getInitialY())) state=np.asarray(p.getView(p.getPos(),self.span)) self.stateList.append(state) self.history+="#"+p.getName()+"-"+p.getPos().CordToString() self.history+="|" self.shortestRoute=len(self.maze.GetOptimalRoute()[0]) return self.stateList
def reset(self): #print("Resetting") self.maze = Maze(self.maze.mazeString) self.pList = [] self.qList = [] self.mList = [] self.pPos = [] self.qPos = [] self.mPos = [] self.pStateList = [] self.mStateList = [] self.qStateList = [] self.finishedP = [] self.finishedQ = [] self.history = self.maze.mazeString + "|" + "0" self.finished = 0 self.finishedP = [] self.count = 0 self.queenLeft = False self.maxIter = 10 * self.maze.height * self.maze.width for j in range(self.wNumber): p = Worker(self.maze, self.spanP) self.pList.append(p) for k in range(self.qNumber): q = Queen(self.maze) self.qList.append(q) for h in range(self.sNumber): s = Spider(self.maze) self.mList.append(s) #print(len(self.pList),len(self.qList),len(self.mList)) self.eaten = 0 self.queenEaten = False for p in self.pList: p.setInitPos(Cord(self.maze.getInitialX(), self.maze.getInitialY())) self.pPos.append(p.getPos()) for q in self.qList: q.setInitPos(Cord(self.maze.getInitialX(), self.maze.getInitialY())) self.qPos.append(q.getPos()) for q in self.mList: q.setInitPos(Cord(q.start.X, q.start.Y)) self.mPos.append(q.getPos()) for p in self.pList: state = np.asarray( p.getAugView(p.getPos(), self.spanP, self.pPos, self.qPos, self.mPos)) self.pStateList.append(state) self.history += "#" + p.getName() + "-" + p.getPos().CordToString() for q in self.qList: #state=np.asarray(p.getAugView(p.getPos(),self.spanP,self.pPos, self.qPos, self.mPos)) #self.pStateList.append(state) self.history += "#" + q.getName() + "-" + q.getPos().CordToString() for q in self.mList: state = np.asarray( q.getAugView(q.getPos(), self.spanM, self.pPos, self.qPos, self.mPos)) self.mStateList.append(state) self.history += "#" + q.getName() + "-" + q.getPos().CordToString() self.history += "|" self.shortestRoute = len(self.maze.GetOptimalRoute()[0]) self.pReward = 0 self.qReward = 0 self.mReward = 0 #print(self.maze.mazeString) #self.maze.printMaze() return self.pStateList