void quantizeBits(){ // *** 0 bugs *** repeat(10){ //repeat 10 times for 10 lines, checking every time if(!onBeeper()){if(frontIsClear()){moveForward();}} //skip an emtpy line else{ //if on Beeper, do initial scan movement and choice qB_move(); qB_choice(); } } } void qB_move(){ turnLeft(); repeat(5){if(frontIsClear()){moveForward();}} } void qB_choice(){ //choose between line is >5 or <6 if(!onBeeper()){qB_smaller();} else{qB_greater();} } void qB_greater(){ //if line is >5 repeat(4){ //go remaining tiles and place Beepers moveForward(); if(!onBeeper()){dropBeeper();} } //return to bottom and step into next line turnAround(); while(frontIsClear()){moveForward();} turnLeft(); if(frontIsClear()){moveForward();} } void qB_smaller(){ //if line is <6 turnAround(); repeat(5){ //return to bottom and pick up all Beepers if(frontIsClear()){moveForward();} if(onBeeper()){pickBeeper();} } //step into next line turnLeft(); if(frontIsClear()){moveForward();} }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter