Dynamic Points

Nobody wants a lot of maths in the code. This is why we have come up with the concept of a Dynamic Point. You can think of it as "Instructions on how to calculate the point we need". A Dynamic Point has three methods:

A trivial example could be the ConstantPoint, which does not change ever:

			public class ConstantPoint extends DynamicPointBase {
			    public ConstantPoint(int x, int y){
			        this.x = x;
			        this.y = y;
			    }

			    @Override
			    public void recalculate() {}

			    @Override
			    public int getX() {
			        return this.x;
			    }

			    @Override
			    public int getY() {
			        return this.y;
			    }
			}
		

A more complex point could be the BallPoint, which always follows the ball:

			public class BallPoint extends DynamicPointBase {
			    @Override
			    public void recalculate() {
			        Ball ball = Strategy.world.getBall();
			        if(ball != null){
			            this.x = (int)ball.location.x;
			            this.y = (int)ball.location.y;
			        } else {
			            RobotType probableHolder = Strategy.world.getProbableBallHolder();
			            if(probableHolder != null){
			                Robot p = Strategy.world.getRobot(probableHolder);
			                if(p != null){
			                    this.x = (int)p.location.x;
			                    this.y = (int)p.location.y;
			                }
			            }
			        }
			    }

			    @Override
			    public int getX() {
			        return this.x;
			    }

			    @Override
			    public int getY() {
			        return this.y;
			    }
			}
		

You get the idea.. Basically, these points are used everywhere. The MotionController and Navigation System make use of these points, so does the ActionController. It is a failsafe way to do maths, because you never write it twice. This is the structure: