Beispiel #1
0
void run() {
/* BEGIN SOLUTION */
	int state = 0 ;
	angleSum = 0;
	setDirection(chosenDirection);
	while ( !isOverBaggle() ){
		switch ( state ){
		case 0: // North runner mode
			while ( !isFacingWall() )
				forward(1);

			right(); // make sure that we have a left wall
			angleSum--;
			state = 1; // time to enter the Left Follower mode
			break;
		case 1: // Left Follower Mode
			stepHandOnWall(); // follow the left wall
			if ( isChosenDirectionFree() && angleSum == 0  )
				state =0; // time to enter in North Runner mode

			break;
		}
	}
	pickupBaggle();
}
void run(){
	/* BEGIN TEMPLATE */
	/* BEGIN SOLUTION */
	while(!isOverBaggle()){
		forward(1);
	}
	/* END SOLUTION */
	/* END TEMPLATE */
}
Beispiel #3
0
void run(){
	#line 1 "RunFour"
	/* BEGIN SOLUTION */
	int cpt = 0;
	while (cpt != 4) {
		forward(1);
		if (isOverBaggle())
			cpt++;
	}
	/* END SOLUTION */
}
Beispiel #4
0
/* BEGIN TEMPLATE */
void hunt(Color c) {
	/* BEGIN SOLUTION */
	while (! isOverBaggle()) {
		if (isFacingTrail(c)) {
			brushDown();
			forward(1);
			brushUp();
		} else {
			left();
		}
	}
	pickupBaggle();
}
Beispiel #5
0
/* BEGIN SOLUTION */
void goAndGet() {
	int i = 0;
	while (!isOverBaggle()) {
		i++;
		forward(1);
	}
	pickupBaggle();
	while (i>0) {
		backward(1);
		i--;
	}
	dropBaggle();
}
void run() {

	/* BEGIN SOLUTION */
	// Make sure we have a wall to the left
	left();
	while (!isFacingWall())
		forward(1);
	right();

	while (!isOverBaggle())
		stepHandOnWall();
	pickupBaggle();
}
Beispiel #7
0
/* BEGIN TEMPLATE */
void run() {
	// Your code here =)
	/* BEGIN SOLUTION */
	while (!isOverBaggle()) {
		switch(random3()) {
		case 0:
			if (!isFacingWall()){
				forward(1);
			}
			break;
		case 1:
			left();
			break;
		case 2:
			right();
			break;
		}
	}
	//pickupBaggle();
	/* END SOLUTION */
}
void followShortestPath() {
	while (! isOverBaggle()) {

		int x = getX();
		int y = getY();

		int topValue = 9999;
		int bottomValue = 9999;
		int leftValue = 9999;
		int rightValue = 9999;

		if (! hasTopWall(x, y))
			topValue = getIndication(x, (y + getWorldHeight() - 1) % getWorldHeight());

		if (! hasBottomWall(x, y))
			bottomValue = getIndication(x, (y+1) % getWorldHeight());

		if (! hasLeftWall(x, y))
			leftValue = getIndication((x +getWorldWidth() - 1) % getWorldWidth(), y);

		if (! hasRightWall(x, y))
			rightValue = getIndication((x + 1) % getWorldWidth(), y);

		if (topValue <= bottomValue && topValue <= leftValue && topValue <= rightValue)
			setDirection(NORTH);
		else if (rightValue <= topValue && rightValue <= bottomValue && rightValue <= leftValue)
			setDirection(EAST);
		else if (leftValue <= rightValue && leftValue <= bottomValue && leftValue <= topValue)
			setDirection(WEST);
		else if (bottomValue <= topValue && bottomValue <= rightValue && bottomValue <= leftValue)
			setDirection(SOUTH);

		forward(1);
	}
	/* END SOLUTION */
}