Vec2 TocchetMode() { abstract_robot.setDisplayString("Tocchet"); Vec2 Goalie = new Vec2(99999, 0); Vec2 GoalDistance = new Vec2(99999, 0); Vec2 CmdReturn; for (int i = 0; i < CurOpponents.length; i++) { if (ClosestTo(CurOpponents[i], EgoToAbs(CurOpponentsGoal))) { Goalie.setx(CurOpponents[i].x); Goalie.sety(CurOpponents[i].y); } } return (Goalie); }
Vec2 GoalieMode() { abstract_robot.setDisplayString("Goalie"); Vec2 ReturnCmd = new Vec2(CurOurGoal.x, CurOurGoal.y); // If we're too far out of goal in x dir, get back in! Vec2 OurGoalAbs = new Vec2(CurOurGoal.x, CurOurGoal.y); OurGoalAbs.add(CurMyPos); if (Math.abs(CurMyPos.x) < Math.abs(OurGoalAbs.x * 0.9)) { return (CurOurGoal); } // Otherwise, calculate projected ball trajectory Vec2 BallDir = new Vec2(CurBallPos.x, CurBallPos.y); BallDir.sub(PrevBallPos); // If ball is headed into goal, block it! ReturnCmd.setx(0); boolean MoveUp = false; boolean MoveDown = false; if (CurMyPos.y < CurBallPos.y) MoveUp = true; if (CurMyPos.y > CurBallPos.y) MoveDown = true; if (CurMyPos.y > GOAL_WIDTH / 2.0) MoveUp = false; if (CurMyPos.y < -GOAL_WIDTH / 2.0) MoveDown = false; if (MoveDown && MoveUp) { ReturnCmd.sety(0); // System.out.println("Both " + CurMyPos.y + " " + CurBallPos.y); } else if (MoveDown) { ReturnCmd.sety(-1); // System.out.println("Down"); } else if (MoveUp) { ReturnCmd.sety(1); // System.out.println("Up"); } else { ReturnCmd.sety(0); } return (ReturnCmd); }