def tick(self): if self.got_dest_loose(self.calc_defend_pos()): self.crouch() trackBall.tick() else: if self.gotoGlobal(self.calc_defend_pos()): self.faceBall() self.crouch() else: trackBall.tick() return self.running()
def tick(self): gc_info = self.bb.GCInfo trackBall.tick() if not self.bb.motionConnected: self.timer.restart() if not self.timer.finished(): self.timer2.restart() self.initial.tick() self.crouch() self.lookAt(45, 0) return self.running() # if penalised, wait elif gc_info.penalised or gc_info.state is GCInfo.SET: self.lookAt(0, 0) self.crouch() return self.running() else: if gc_info.connected and gc_info.state is GCInfo.INITIAL: self.bb.reentry = False return self.success() if gc_info.connected and gc_info.state is GCInfo.PLAYING and self.bb.see_ball and self.bb.see_ball_cnt > 5: self.bb.reentry = False return self.success() self.dest = self.bb.get_default_dest() if not self.got_dest_loose(self.dest): self.gotoGlobal(self.dest) return self.running() else: self.crouch() self.bb.reentry = False return self.success()
def tick(self): if self.bb.see_ball: self.lostBallTimer.restart() if self.lostBallTimer.elapsed() > 15: self.gotoGlobal(self.bb.get_default_dest()) if self.got_dest_loose(self.bb.get_default_dest()): self.lostBallTimer.restart() elif self.bb.closest_to_ball() or self.bb.team_lost_ball(): self.ready = False self.strike.tick() else: """ Face ball if see ball, else seek ball Approach close to ball Keep 1m away, don't block attack path """ if self.bb.see_ball: bally = self.bb.ball_global.y ballx = self.bb.ball_global.x rx = self.bb.robot_pos.x ry = self.bb.robot_pos.y dx = rx - ballx dy = ry - bally dist = sqrt(dx * dx + dy * dy) # for attack right case change = False if attackRight(): if ballx > rx or abs(bally - ry) > 150 or dist > 200 or dist < 50: if ry > bally: y = bally + 100 else: y = bally - 100 angle = degree_between(self.bb.robot_pos, self.bb.ball_global) if not self.gotoGlobal(VecPos(ballx + 100, y, angle)): change = True else: if ballx < rx or abs(bally - ry) > 150 or dict > 200 or dist < 50: if ry > bally: y = bally + 100 else: y = bally - 100 angle = degree_between(self.bb.robot_pos, self.bb.ball_global) if not self.gotoGlobal(VecPos(ballx + 100, y, angle)): change = True trackBall.tick() if not change: self.faceBall() else: # to do, max turn cnt, else go back self.seekball.tick() return self.running()