if (knitr:::is_latex_output()) {
knitr::asis_output('\\url{....}')
} else {
knitr::include_graphics("fig/Around_01.gif")
}
move(), turn_left(), put()move(), turn_left(), put()front_is_clear(), wall_in_front(), object_here()while, repeat/for 루프와 제어 if문if (knitr:::is_latex_output()) {
knitr::asis_output('\\url{....}')
} else {
knitr::include_graphics("fig/Around_01.gif")
}
repeat 4 :
repeat 9 :
move()
turn_left()리보그가 토큰(token)을 가지고 다니는 점을 이용하여 리보그 세상을 한바퀴 삥 둘러 돌아다닌 후에 제자리로 돌아온 위치를 표식하고 이를 프로그램 종료 조건으로 설정한다.
move(), turn_left(), put()front_is_clear(), wall_in_front(), right_is_clear(), wall_on_right(), object_here()while, repeat/for 루프와 제어 if문if (knitr:::is_latex_output()) {
knitr::asis_output('\\url{....}')
} else {
knitr::include_graphics("fig/Around_02.gif")
}
def turn_right():
turn_left()
turn_left()
turn_left()
# 목표지점 표식
def drop_token():
put("token")
drop_token()
move()
while not object_here():
move()
if wall_in_front() :
turn_left()
if right_is_clear() :
turn_right()
move()Around 2와 마찬가지로 토큰을 떨어뜨려 표식을 하고 자리를 한칸 이동한 후에 돌아다니는 작업을 수행한다.
move(), turn_left(), put()front_is_clear(), wall_in_front(), right_is_clear(), wall_on_right(), object_here()while, repeat/for 루프와 제어 if문if (knitr:::is_latex_output()) {
knitr::asis_output('\\url{....}')
} else {
knitr::include_graphics("fig/Around_03.gif")
}
def turn_right():
turn_left()
turn_left()
turn_left()
# 목표지점 표식
def drop_token():
put("token")
drop_token()
turn_left()
move()
while not object_here():
if right_is_clear():
turn_right()
move()
elif front_is_clear():
move()
else:
turn_left()본 문제를 해결하게 되면 앞선 Around 1,2,3번 문제도 작성한 프로그램으로 일반화시켜 해결할 수 있다.
move(), turn_left(), put()front_is_clear(), wall_in_front(), right_is_clear(), wall_on_right(), object_here()while, if/elif/else 문if (knitr:::is_latex_output()) {
knitr::asis_output('\\url{....}')
} else {
knitr::include_graphics("fig/Around_04.gif")
}
def turn_right():
turn_left()
turn_left()
turn_left()
def turn_around():
turn_left()
turn_left()
# 목표지점 표식
def drop_token():
put("token")
drop_token()
turn_around()
move()
while not object_here():
if right_is_clear():
turn_right()
move()
elif front_is_clear():
move()
else:
turn_left()