// Initialize the current color var currentColor = black;
function start() leftIsBlocked() // Fills an entire row with alternating balls function buildRow() putBall(); while (frontIsClear()) move(); if (frontIsClear()) move(); putBall(); // Safely turns Karel around to the next level up function repositionToNextRow() if (facingEast()) turnLeftToNextRow(); else if (facingWest()) turnRightToNextRow(); function turnLeftToNextRow() turnLeft(); if (frontIsClear()) move(); turnLeft(); function turnRightToNextRow() turnRight(); if (frontIsClear()) move(); turnRight(); Use code with caution. 645 checkerboard karel answer verified
private void setKarelsDirection() if (facingEast()) if (frontIsBlocked()) turnLeft(); // Initialize the current color var currentColor =