def jproall(self): dist = 9999 vec = Vector2D(0, 0) if (self.team == 1): for p in self.state.team1: if (p.position != self.player.position): distmebut = self.state.get_goal_center( outils.IDTeamOp(self.team)) - self.player.position distluibut = self.state.get_goal_center( outils.IDTeamOp(self.team)) - p.position distmelui = p.position - self.player.position if (distluibut.norm < distmebut.norm and distmelui.norm < dist): dist = distmelui.norm vec = p.position else: for p in self.state.team2: if (p.position != self.player.position): distmebut = self.state.get_goal_center( outils.IDTeamOp(self.team)) - self.player.position distluibut = self.state.get_goal_center( outils.IDTeamOp(self.team)) - p.position distmelui = p.position - self.player.position if (distluibut.norm < distmebut.norm and distmelui.norm < dist): dist = distmelui.norm vec = p.position return vec.copy()
def nbadvbalbut(self, adv): nb = 0 if ((self.team == 2 and adv) or (self.team == 1 and not adv)): for p in self.state.team1: if (adv): distun = self.state.get_goal_center( outils.IDTeamOp(self.team)) - p.position distdeux = self.state.get_goal_center( outils.IDTeamOp(self.team)) - self.state.ball.position else: distun = self.state.get_goal_center(self.team) - p.position distdeux = self.state.get_goal_center( self.team) - self.state.ball.position if (distun.norm < distdeux.norm): nb = nb + 1 else: for p in self.state.team2: if (adv): distun = self.state.get_goal_center( outils.IDTeamOp(self.team)) - p.position distdeux = self.state.get_goal_center( outils.IDTeamOp(self.team)) - self.state.ball.position else: distun = self.state.get_goal_center(self.team) - p.position distdeux = self.state.get_goal_center( self.team) - self.state.ball.position if (distun.norm < distdeux.norm): nb = nb + 1 return nb
def compute_strategy(self, state, player, teamid): outil = Outils(state, teamid, player) loc1 = outil.moncopain().copy() if (outil.hautterrain()): mouvement = state.get_goal_center( outils.IDTeamOp(teamid)) + Vector2D(0, 14) - player.position else: mouvement = state.get_goal_center( outils.IDTeamOp(teamid)) + Vector2D(0, -14) - player.position mouvement.norm = mouvement.norm * 0.4 if (outil.canshoot()): return SoccerAction(Vector2D(0, 0), mouvement) else: return SoccerAction(Vector2D(0, 0), Vector2D(0, 0))
def compute_strategy(self, state, player, teamid): test = Outils(state, teamid, player) dist = state.ball.position - player.position but = state.get_goal_center(outils.IDTeamOp(teamid)) - player.position butx = state.get_goal_center( outils.IDTeamOp(teamid)).x - player.position.x if (test.nbadvbalbut(True) == 4 and self.attente >= 1): self.attente = self.attente - 1 return self.inter.compute_strategy(state, player, teamid) if ((test.nbadvbalbut(True) >= 1 or self.attente < 1) and abs(butx) > 15): return self.atck.compute_strategy(state, player, teamid) else: return self.fonceur.compute_strategy(state, player, teamid)
def compute_strategy(self, state, player, teamid): outil = Outils(state, teamid, player) allie = outil.jproall() dist = state.ball.position - player.position.copy() but = state.get_goal_center( outils.IDTeamOp(teamid)) - player.position.copy() dist2 = state.ball.position - allie if (not outil.equiperbal()): but = state.get_goal_center( outils.IDTeamOp(teamid)).x - player.position.copy().x if (abs(but) < 15 or outil.nbadvbalbut(True) < 1): return self.but.compute_strategy(state, player, teamid) else: return self.esquive.compute_strategy(state, player, teamid) else: return self.suivre.compute_strategy(state, player, teamid)
def compute_strategy(self, state, player, teamid): test = Outils(state, teamid, player) tir = state.get_goal_center(outils.IDTeamOp(teamid)) - player.position tir.norm = tir.norm * 0.3 if (test.canshoot()): return SoccerAction(Vector2D(0, 0), tir) else: return SoccerAction(Vector2D(0, 0), Vector2D(0, 0))
def compute_strategy(self, state, player, teamid): dri = state.get_goal_center(outils.IDTeamOp(teamid)) - player.position test = Outils(state, teamid, player) if (test.canshoot()): drib = Vector2D.create_polar(dri.angle + random.random() * 2 - 1, 1) else: drib = Vector2D(0, 0) return SoccerAction(Vector2D(0, 0), drib)
def compute_strategy(self, state, player, teamid): test = Outils(state, teamid, player) tir = Vector2D(0, 0) tir = state.get_goal_center(outils.IDTeamOp(teamid)) - player.position if (test.goalsupmid()): tir.x = tir.x - (GAME_GOAL_HEIGHT / 2) * 0.75 tir.y = tir.y - (GAME_GOAL_HEIGHT / 2) * 0.75 else: tir.x = tir.x + (GAME_GOAL_HEIGHT / 2) * 0.75 tir.y = tir.y + (GAME_GOAL_HEIGHT / 2) * 0.75 if (test.canshoot()): return SoccerAction(Vector2D(0, 0), tir) else: return SoccerAction(Vector2D(0, 0), Vector2D(0, 0))
def compute_strategy(self, state, player, teamid): test = Outils(state, teamid, player) # a = self.test.distballon(self.test, teamid, 1) #TEST DEBUG dist = state.ball.position - player.position but = state.get_goal_center( outils.IDTeamOp(teamid)).x - player.position.x if (abs(but) < 15): return self.but.compute_strategy(state, player, teamid) if (dist.norm > 20): self.aballon = 0 if (dist.norm < 3 or self.aballon): self.aballon = 1 return self.atck.compute_strategy(state, player, teamid) else: return self.defen.compute_strategy(state, player, teamid)
def compute_strategy(self, state, player, teamid): out = Outils(state, teamid, player) goal = state.get_goal_center(outils.IDTeamOp(teamid)) yadv = out.jpro().y yme = player.position.y if (yadv > yme): dire = goal - player.position go = Vector2D.create_polar(dire.angle - 0.35, 2) else: dire = goal - player.position go = Vector2D.create_polar(dire.angle + 0.35, 2) if (out.canshoot()): return SoccerAction(Vector2D(0, 0), go) else: return SoccerAction(Vector2D(0, 0), Vector2D(0, 0))