Esempio n. 1
0
    def registerInitialState(self, gameState):
        CaptureAgent.registerInitialState(self, gameState)

        self.teamIndices = CaptureAgent.getTeam(
            self,
            gameState)  #Array representing the indices of every ally Agent
        self.opponentIndices = CaptureAgent.getOpponents(
            self,
            gameState)  #Array representing the indices of every oponent Agent

        if self.index == self.teamIndices[
                0]:  #Determine which index information about this Agent can be found. That includes who it's going after (if it's on defense) and where it is
            self.teamOrder = 0
        elif self.index == self.teamIndices[1]:
            self.teamOrder = 1

        position = gameState.getAgentPosition(
            self.index
        )  #This figures out where the boundary between either side is
        gameMap = gameState.getWalls()
        boundary = gameMap.width / 2
        if position[0] < boundary:
            self.leftEdge = 0  #The farthest left the Agent can go and still be on it's home side
            self.rightEdge = boundary  #The farthest left the Agent can go and be on the opponent side
            self.boundary = boundary - 1  #The place on the home side closest to the far side
        else:
            self.leftEdge = boundary  #All these variables are the same as above.
            self.rightEdge = gameMap.width
            self.boundary = boundary
Esempio n. 2
0
    def registerInitialState(self, gameState):
        """
    This method handles the initial setup of the
    agent to populate useful fields (such as what team
    we're on).

    A distanceCalculator instance caches the maze distances
    between each pair of positions, so your agents can use:
    self.distancer.getDistance(p1, p2)

    IMPORTANT: This method may run for at most 15 seconds.
    """
        '''
    Make sure you do not delete the following line. If you would like to
    use Manhattan distances instead of maze distances in order to save
    on initialization time, please take a look at
    CaptureAgent.registerInitialState in captureAgents.py.
    '''
        self.start = gameState.getAgentPosition(self.index)
        self.team = CaptureAgent.getTeam(self, gameState)
        self.food = CaptureAgent.getFood(self, gameState)
        self.foodDefending = CaptureAgent.getFoodYouAreDefending(
            self, gameState)
        self.opponents = CaptureAgent.getOpponents(self, gameState)
        print("Start: ", self.start, "Team: ", self.team, "Food: ", self.food,
              "Food Defending:", self.foodDefending, "Opponent: ",
              self.opponents)
        CaptureAgent.registerInitialState(self, gameState)
        '''
Esempio n. 3
0
 def registerInitialState(self, gameState):
     CaptureAgent.registerInitialState(self, gameState)
     self.myAgents = CaptureAgent.getTeam(self, gameState)
     self.opponentsAgents = CaptureAgent.getOpponents(self, gameState)
     self.myFoods = CaptureAgent.getFood(self, gameState).asList()
     self.opponentsFoods = CaptureAgent.getFoodYouAreDefending(
         self, gameState).asList()
Esempio n. 4
0
	def registerInitialState(self, gameState):
		"""
		This method handles the initial setup of the
		agent to populate useful fields (such as what team
		we're on).
		"""

		CaptureAgent.registerInitialState(self, gameState)
		self.myAgents = CaptureAgent.getTeam(self, gameState)
		self.opAgents = CaptureAgent.getOpponents(self, gameState)
		self.myFoods = CaptureAgent.getFood(self, gameState).asList()
		self.opFoods = CaptureAgent.getFoodYouAreDefending(self, gameState).asList()
Esempio n. 5
0
    def registerInitialState(self, gameState):
        CaptureAgent.registerInitialState(self, gameState)

        self.teamIndices = CaptureAgent.getTeam(self, gameState)
        self.opponentIndices = CaptureAgent.getOpponents(self, gameState)
        self.enemyPos = [None, None]

        position = gameState.getAgentPosition(
            self.index
        )  #This figures out where the boundary between either side is
        gameMap = gameState.getWalls()
        boundary = gameMap.width / 2
        if position[0] < boundary:
            self.leftEdge = 0
            self.rightEdge = boundary
        else:
            self.leftEdge = boundary
            self.rightEdge = gameMap.width
Esempio n. 6
0
	def registerInitialState(self, gameState):
		CaptureAgent.registerInitialState(self, gameState)
		self.init = gameState.getAgentState(self.index).getPosition()
		self.epsilon = 0.0#exploration prob
		self.alpha = 0.1 #learning rate
		self.discountRate = 0.8
		self.dangeFood = []
		self.mode = 1
		self.weights1 = {'closest-food': 2.35219445732408, 'bias': 2.579502234147277, 'closest-capsule': 2.473714473123398}
		self.weights2 = {'closest-food': 1.02910769618005556, 'bias': -6.112936837778204, 'closest-ghosts': -10.11587156566253, 'closest-capsule': 1.257363246901937, 'num-of-walls': -10.4903928122119086, 'time-of-scared-ghosts': 1.6265815562445105, 'reverse': -2.732599631268455}
		self.weights3 = {'bias': -0.1619191782335229, 'closest-ghosts': -18.645334316865307, 'num-of-walls': -10.45335435502801, 'distance-back-to-home': 2.0996715469522775, 'time-of-scared-ghosts': 0.7966612961334337, 'reverse': -2.732599631268455,'closest-capsule': 4.523232232232323}										
		self.weights4 = {'bias': 6.802602309336149, 'distance-back-to-home': 12.7541385540534}
		self.finish = False
		self.myAgents = CaptureAgent.getTeam(self, gameState)
		self.opAgents = CaptureAgent.getOpponents(self, gameState)
		self.myFoods = CaptureAgent.getFood(self, gameState).asList()
		self.opFoods = CaptureAgent.getFoodYouAreDefending(self, gameState).asList()
		self.lostFoods = []
		self.gamescore = 0

		self.midWidth = gameState.data.layout.width / 2
		self.height = gameState.data.layout.height
		self.width = gameState.data.layout.width
		self.midHeight = gameState.data.layout.height / 2