3525 ms / 9 phrases / 9 phrases
robo_forward()
robo_left()
robo_forward()
robo_forward()
robo_forward()
robo_left()
robo_forward()
robo_left()
robo_forward()
18 800 ms / 4 phrases / 52 phrases
loop
robo_forward()
robo_left()
robo_forward()
2 625 ms / 6 phrases / 11 phrases
robo_forward()
if robo_scan() is -1
# todo
robo_left()
robo_forward()
44 900 ms / 7 phrases / 294 phrases
loop
var scan = robo_scan()
if scan >= 1
robo_forward()
else
robo_left()
119 550 ms / 13 phrases / 915 phrases
loop
var scan = robo_scan()
if scan <= -1
robo_left()
else
robo_forward()
if scan is 10
if robo_use() is 0
robo_use()
42 125 ms / 24 phrases / 395 phrases
var exit_location
loop
var scan = robo_scan()
if scan >= 1
robo_forward()
if scan is 11
exit_location = robo_use()
break
else
robo_left()
loop
var scan = robo_scan()
if scan >= 1 or scan is -999 and robo_forward_location() is exit_location
robo_forward()
else
robo_left()
176 700 ms / 40 phrases / 2 446 phrases
var safe_location1 = 0
var safe_location2 = 0
var safe_location3 = 0
var safe_location4 = 0
loop
var scan = robo_scan()
var forward_location = robo_forward_location()
if scan >= 1
robo_forward()
if scan is 10
if not robo_use()
robo_use()
else if scan is 11
if safe_location1 is 0
safe_location1 = robo_use()
else if safe_location2 is 0
safe_location2 = robo_use()
else if safe_location3 is 0
safe_location3 = robo_use()
else
safe_location4 = robo_use()
else if forward_location is safe_location1 or forward_location is safe_location2 or forward_location is safe_location3 or forward_location is safe_location4
robo_forward()
else
robo_left()
42 125 ms / 24 phrases / 395 phrases
var start = robo_location()
while robo_forward_location() is not start
if robo_scan() > 0
robo_forward()
else
robo_left()
robo_left()
robo_left()
loop
if robo_scan() > 0
robo_forward()
else
robo_left()
23 300 ms / 51 phrases / 316 phrases
var turns = 0
loop
var scan = robo_scan()
if scan > 0
robo_forward()
turns = (turns + 6 - 1) % 6
while scan is 12
var direction = robo_use()
if direction is 1
if turns is 0
robo_forward()
turns = (turns + 6 - 1) % 6
if turns is 4
robo_left()
turns = (turns + 2) % 6
robo_forward()
turns = (turns + 6 - 1) % 6
else if direction is 2
if turns is 4 or turns is 5
robo_forward()
turns = (turns + 6 - 1) % 6
else if turns is 3
robo_left()
turns = (turns + 2) % 6
robo_forward()
turns = (turns + 6 - 1) % 6
else if turns is 0 or turns is 1 or turns is 2
robo_left()
turns = (turns + 2) % 6
robo_left()
turns = (turns + 2) % 6
robo_forward()
turns = (turns + 6 - 1) % 6
else
robo_left()
turns = (turns + 2) % 6
62 475 ms / 58 phrases / 1 490 phrases
var turns = 0
fun forward()
robo_forward()
turns = (turns + 6 - 1) % 6
fun left()
robo_left()
turns = (turns + 2) % 6
fun to_turns(direction)
if direction is 1
return 0
if direction is 3
return 3
if direction is 2
if turns % 2 is 0
return 4
else
return 5
if direction is 4
if turns % 2 is 0
return 2
else
return 1
fun use_direction()
return to_turns(robo_use())
var scan = robo_scan()
loop
if scan > 0
forward()
while scan is 12
var direction = use_direction()
if (direction - turns % 6 + 6) % 6 is 2
left()
else if (direction - turns % 6 + 6) % 6 is 4
left()
left()
scan = robo_scan()
forward()
else
left()
57 500 ms / 66 phrases / 1 139 phrases
var turns = 0
fun forward()
robo_forward()
turns = (turns + 6 - 1) % 6
fun left()
robo_left()
turns = (turns + 2) % 6
fun to_turns(direction)
if direction is 1
return 0
if direction is 3
return 3
if direction is 2
if turns % 2 is 0
return 4
else
return 5
if direction is 4
if turns % 2 is 0
return 2
else
return 1
fun use_direction()
return to_turns(robo_use())
var safe_location = 0
loop
var scan = robo_scan()
if scan > 0 or robo_forward_location() is safe_location
forward()
if scan is 11
safe_location = robo_use()
while scan is 12
var direction = use_direction()
if (direction - turns % 6 + 6) % 6 is 2
left()
else if (direction - turns % 6 + 6) % 6 is 4
left()
left()
scan = robo_scan()
forward()
else
left()
58 450 ms / 10 phrases / 330 phrases
var adjacent
loop
adjacent = robo_detect_adjacent()
if adjacent is 3
robo_forward()
else
robo_left()
robo_left()
robo_forward()
69 800 ms / 29 phrases / 513 phrases
loop
var forward = robo_scan()
var adjacent = robo_detect_adjacent()
if forward > 0 or adjacent is 3
robo_forward()
continue
robo_left()
var left = robo_scan()
if left > 0
robo_forward()
continue
if forward is -1 and adjacent >= 2
robo_forward() # left
continue
if left is -1 and adjacent >= 2
robo_left()
robo_left()
robo_forward()
continue
219 575 ms / 47 phrases / 3 475 phrases
Thanks to this video: https://www.youtube.com/watch?v=1OXD4ys92Zk
seq bad[]
var detect
fun bad_id(id)
for x in bad[]
if x is id
return 1
return 0
robo_forward()
loop
detect = robo_detect_adjacent()
if detect is 2
var id = robo_forward_location()
var scan = robo_scan()
if scan is -1 or scan is -999
robo_left()
if scan is -999 and not bad_id(id)
scan = robo_scan()
if scan > 0
bad[].add(id)
else
bad[].add(robo_forward_location())
robo_left()
robo_left()
else if detect is 1
bad[].add(robo_forward_location())
robo_left()
bad[].add(robo_forward_location())
robo_left()
else if detect is 3 and bad_id(robo_forward_location())
robo_left()
robo_forward()
329 150 ms / 86 phrases / 7 573 phrases
var LOCATION_DATA_STORE = 11
var UNKNOWN = -999
var DIRECTION_DATA_STORE = 12
var turns
seq safe[]
fun contains(array[], item)
for x in array[]
if x is item
return 1
return 0
fun add_distinct(array[], item)
if not array[].contains(item)
array[].add(item)
fun forward()
robo_forward()
turns = ((turns - 1) % 6 + 6) % 6
fun left()
robo_left()
turns = (turns + 2) % 6
fun to_turns(direction)
if direction is 1 # up
return 0
if direction is 2 # right
if turns % 2 is 0
return 4
else
return 5
if direction is 3 # down
return 3
if direction is 4 # left
if turns % 2 is 0
return 2
else
return 1
pause()
turns = 0
loop
var scan = robo_scan()
if scan > 0
forward()
if scan is LOCATION_DATA_STORE
safe[].add_distinct(robo_use())
else
while scan is DIRECTION_DATA_STORE
var direction = robo_use()
if direction is 0
break
var safe_turns = direction.to_turns()
# if (turns % 2) is not (safe_turns % 2) pause()
if (safe_turns - turns + 6) % 6 is 2
left()
else if (safe_turns - turns + 6) % 6 is 4
left()
left()
safe[].add_distinct(robo_forward_location())
scan = robo_scan()
forward()
continue
else if scan is -999
var forward_location = robo_forward_location()
if safe[].contains(forward_location)
forward()
continue
left()