def chooseCapsules(self, gameState, capsuleLimit, opponentEvidences): # Do custom processing on the opponent's power evidence in order to # effectively choose your capsules. # net = contestPowersBayesNet.powersBayesNet() # for instance to calculate the joint distribution of the # enemy agent 0 choosing invisibility and speed: # from inference import inferenceByVariableElimination # jointSpeedInvisibility = inferenceByVariableElimination(net, # ['invisibility', 'speed'], # opponentEvidences[0], None) # or compute the marginal factors of the enemy powers, given the # evidenceAssignmentDict of the sum variables in the enemy powersBayesNet # enemyAgentMarginals = [] # for evidence in opponentEvidences: # marginals = contestPowersBayesNet.computeMarginals(evidence) # enemyAgentMarginals.append(marginals) # now perform other inference for other factors or use these marginals to # choose your capsules # these are not good choices, this is just to show you how to choose capsules width, height = gameState.data.layout.width, gameState.data.layout.height leftCapsules = [] while len(leftCapsules) < (capsuleLimit / 2): x = random.randint(1, (width / 2) - 1) y = random.randint(1, height - 2) if gameState.isValidPosition((x, y), self.isRed): leftCapsules.append(ScareCapsule(x, y)) rightCapsules = [] while len(rightCapsules) < (capsuleLimit / 2): x = random.randint((width / 2), width - 2) y = random.randint(1, height - 2) if gameState.isValidPosition((x, y), self.isRed): rightCapsules.append(ScareCapsule(x, y)) return leftCapsules + rightCapsules
def chooseCapsules(self, gameState, capsule_limit, opponent_evidences): width, height = gameState.data.layout.width, gameState.data.layout.height left_caps, right_caps = [], [] while len(left_caps) < (capsule_limit / 2): x = random.randint(1, (width / 2) - 1) y = random.randint(1, height - 2) if gameState.isValidPosition((x, y), self.isRed): if self.isRed: if len(left_caps) % 2 == 0: left_caps.append(ArmourCapsule(x, y)) else: left_caps.append(JuggernautCapsule(x, y)) else: if len(left_caps) % 2 == 0: left_caps.append(SonarCapsule(x, y)) else: left_caps.append(ScareCapsule(x, y)) while len(right_caps) < (capsule_limit / 2): x = random.randint(1, (width / 2) - 1) y = random.randint(1, height - 2) if gameState.isValidPosition((x, y), self.isRed): if self.isRed: if len(right_caps) % 2 == 0: right_caps.append(SonarCapsule(x, y)) else: right_caps.append(ScareCapsule(x, y)) else: if len(left_caps) % 2 == 0: right_caps.append(ArmourCapsule(x, y)) else: right_caps.append(JuggernautCapsule(x, y)) return left_caps + right_caps
def chooseCapsules(self, gameState, capsuleLimit, opponentEvidences): width, height = gameState.data.layout.width, gameState.data.layout.height leftCapsules = [] while len(leftCapsules) < (capsuleLimit / 2): x = random.randint(1, (width / 2) - 1) y = random.randint(1, height - 2) if gameState.isValidPosition((x, y), self.isRed): leftCapsules.append(ScareCapsule(x, y)) rightCapsules = [] while len(rightCapsules) < (capsuleLimit / 2): x = random.randint((width / 2), width - 2) y = random.randint(1, height - 2) if gameState.isValidPosition((x, y), self.isRed): rightCapsules.append(ScareCapsule(x, y)) return leftCapsules + rightCapsules
def chooseCapsules(self, gameState, capsuleLimit, opponentEvidences): P = PowersInference() e_1 = [ opponentEvidences[0]['sum0'], opponentEvidences[0]['sum1'], opponentEvidences[0]['sum2'], opponentEvidences[0]['sum3'] ] e_2 = [ opponentEvidences[1]['sum0'], opponentEvidences[1]['sum1'], opponentEvidences[1]['sum2'], opponentEvidences[1]['sum3'] ] P.infer(e_1, 0) P.infer(e_2, 1) #Tells us maze distances distancer = distanceCalculator.Distancer(gameState.data.layout) distancer.getMazeDistances() kmeans = KMeans(gameState, self.isRed) food = gameState.getRedFood().asList( ) if not self.isRed else gameState.getBlueFood().asList() scare_locations = kmeans.pick_capsules(food, distancer) capsules = [] for location in scare_locations: x, y = location capsules.append(ScareCapsule(x, y)) """ grenade_locations = self.pick_grenades( gameState, distancer ) for (x, y) in grenade_locations: capsules.append( GrenadeCapsule(x, y) ) """ return capsules
def chooseCapsules(self, gameState, capsuleLimit, opponentEvidences): width, height = gameState.data.layout.width, gameState.data.layout.height y = 1 mid_left = width / 2 - 1 leftCapsules = [] while len(leftCapsules) < (capsuleLimit / 2): if gameState.isValidPosition((mid_left, y), self.isRed): leftCapsules.append(ScareCapsule(mid_left, y)) y += 1 y = height - 1 mid_right = width / 2 rightCapsules = [] while len(rightCapsules) < (capsuleLimit / 2): if gameState.isValidPosition((mid_right, y), self.isRed): rightCapsules.append(ScareCapsule(mid_right, y)) y -= 1 return leftCapsules + rightCapsules
def chooseCapsules(self, gameState, capsuleLimit, opponentEvidences): width, height = gameState.data.layout.width, gameState.data.layout.height capsules = [] while len(capsules) < capsuleLimit / 4: x = random.randint(1, (width / 2) - 2) y = random.randint(1, (height / 2) - 2) if gameState.isValidPosition((x, y), self.isRed): capsules.append(ScareCapsule(x, y)) while len(capsules) < capsuleLimit / 4: x = random.randint((width / 2) - 2, width - 2) y = random.randint(1, (height / 2) - 2) if gameState.isValidPosition((x, y), self.isRed): capsules.append(ScareCapsule(x, y)) while len(capsules) < capsuleLimit / 4: x = random.randint((width / 2) - 2, width - 2) y = random.randint((height / 2) - 2, height - 2) if gameState.isValidPosition((x, y), self.isRed): capsules.append(ScareCapsule(x, y)) while len(capsules) < capsuleLimit / 4: x = random.randint(1, (width / 2) - 2) y = random.randint((height / 2) - 2, height - 2) if gameState.isValidPosition((x, y), self.isRed): capsules.append(ScareCapsule(x, y)) return capsules