Lawn Mowing

In Class Exercise

package agentSystem;

import igeo.IVec;
import igeo.IPoint;

public class MowingAgent extends Agent {

float vel = 25;
double mowerwidth = 25;
double desiredoverlap = 0.25;
IVec baseDir;
IVec currDir;
boolean done = false;
int time = 0;
IPoint pt;
IVec newPos;
double turn = 1.57;

public MowingAgent(AgentManager _p5, IVec _pos, IVec _bdir) {
super(_p5,_pos); = new IPoint(this.pos);
this.newPos = new IVec(this.pos);
this.baseDir = _bdir;

public void mow() {

//determine which direction I need to be going
//change direction
//turn opposite each time
this.turn = -this.turn;
//turn around and shift down to get the desired mower overlap
this.newPos = this.pos.dup().add(this.currDir.dup().rot(this.turn).len(mowerwidth-(mowerwidth*desiredoverlap)));
//get back into the lawn


//determine how far Im mowing


public boolean inBounds() {
return this.p5.boundaryCrv.isInside2d(this.pos);

public void update() {
if(!done) {
} else {
System.out.println("whew, time for a beer");

public void redraw() {
pt.pos = this.pos;



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s