import org.logic.GyteController;
import org.run.ForcedStopException;

/**
* @author SvenV
* @date 09.01.2021
* @version 1.1.1
*
* This class is the start and heart of every program ran by the GYTE-Processor.
*/
public class GyteProgram {
	// default constructor, must be in here always.
	public GyteProgram() {}

	/* This method is the start where the processor will start executing */
	public void run(GyteController controller) throws ForcedStopException {
		// METHOD: random-walk
		while(true) {
			if (controller.isOnCoin() ) {
				controller.pickup();
				System.out.println("Coin count: " + controller.getCoinCount() );
			}
	
			double number = Math.random();
			
			if (number < 0.5) {	
				if (number < 0.25) {
					controller.turnRight();
				} else {
					controller.turnLeft();
				}
			}
			
			while (controller.hasWallFront() ) {
				if (number < 0.5) {
					controller.turnRight();
				} else {
					controller.turnLeft();
				}
			}

			controller.goForward();	
		}
	}
}