1.1. Harvest ¶
- harvest1.wld ์๋ ํ์ผ์ ์ฐ๋ค.
- ํ์ฌ ์ง๋์ ์๋ ๋ชจ๋ ์จ์์ ์ํํ๋ ๋ก์ง์ ์ง ๋ค.
~cpp
def move_and_pick():
move()
if next_to_a_beeper():
pick_beeper()
def upAndTurnLeft():
turn_left()
move()
pick_beeper()
turn_left()
def upAndTurnRight():
turn_left()
turn_left()
turn_left()
move()
turn_left()
turn_left()
turn_left()
def harvestTwoRow():
repeat(move_and_pick,6)
upAndTurnLeft()
repeat(move_and_pick,6)
upAndTurnRight()
repeat(harvestTwoRow,3)
turn_off()
1.2. ์ ํ์ Harvest ¶
- harvest2.wld ์๋ ํ์ผ์ ์ฐ๋ค.
- ํ์ฌ 2๊ฐ์ธ ์จ์๋ ์์ฌ ์๋ค. ๋ชจ๋ ๋ฐญ์ 1๊ฐ์ธ ์จ์๋ง ์๊ฒ ๋ง๋ ๋ค.
~cpp
next_to_a_carrot=next_to_a_beeper
plant_carrot = put_beeper
pick_carrot = pick_beeper
def pick_TwoCarrot():
if next_to_a_carrot():
pick_carrot()
if not next_to_a_carrot():
plant_carrot()
def one_carrot_only():
if not next_to_a_carrot():
plant_carrot()
def move_and_pick():
if front_is_clear():
move()
pick_TwoCarrot()
else:
upAndTurnLeft()
def move_and_put():
move()
one_carrot_only()
def upAndTurnLeft():
turn_left()
move()
pick_beeper()
turn_left()
def upAndTurnRight():
turn_left()
turn_left()
turn_left()
move()
turn_left()
turn_left()
turn_left()
downAndTurnRight = upAndTurnLeft
downAndTurnLeft = upAndTurnRight
def harvestTwoRow():
repeat(move_and_pick,6)
repeat(move_and_pick,6)
repeat(harvestTwoRow,1)
upAndTurnRight()
repeat(move_and_pick,6)
repeat(move_and_pick,5)
upAndTurnRight()
repeat(move_and_pick,6)
repeat(move_and_pick,5)
one_carrot_only()
turn_left()
turn_left()
repeat(move_and_put,5)
downAndTurnLeft()
one_carrot_only()
repeat(move_and_put,5)
downAndTurnRight()
one_carrot_only()
repeat(move_and_put,5)
downAndTurnLeft()
one_carrot_only()
repeat(move_and_put,5)
downAndTurnRight()
one_carrot_only()
repeat(move_and_put,5)
downAndTurnLeft()
repeat(move_and_put,5)
turn_off()
1.3. ์์์ ๊ฐ์ ์จ๋ฅผ ์ฒ๋ฆฌํ๋ Harvest ¶
- harvest3.wld ์๋ ํ์ผ์ ์ฐ๋ค.
- ํ์ฌ 2๊ฐ ์ด์์ธ ์จ์์ด ๋ฐญ์ ์๋ค. ๋ชจ๋ 1๊ฐ์ธ ์จ์๋ง ์๊ฒ ๋ง๋ ๋ค.
- ์ด ๊ฒฝ์ฐ์์์ ์ฒ๋ฆฌ๋ฅผ while ๋ฌธ์ ์ฌ์ฉํ์ฌ ์ฒ๋ฆฌํ๋ค.
~cpp
next_to_a_carrot=next_to_a_beeper
plant_carrot = put_beeper
pick_carrot = pick_beeper
def upAndTurnLeft():
turn_left()
move()
pick_beeper()
turn_left()
def upAndTurnRight():
turn_left()
turn_left()
turn_left()
move()
turn_left()
turn_left()
turn_left()
downAndTurnRight = upAndTurnLeft
downAndTurnLeft = upAndTurnRight
def pick_TwoCarrot():
if next_to_a_carrot():
while next_to_a_carrot():
pick_carrot()
if not next_to_a_carrot():
plant_carrot()
def one_carrot_only():
if not next_to_a_carrot():
plant_carrot()
def move_and_pick():
if front_is_clear():
move()
pick_TwoCarrot()
else:
upAndTurnLeft()
def move_and_put():
if front_is_clear():
move()
one_carrot_only()
else:
downAndTurnLeft()
def harvestTwoRow():
repeat(move_and_pick,6)
repeat(move_and_pick,6)
repeat(harvestTwoRow,1)
upAndTurnRight()
repeat(move_and_pick,6)
repeat(move_and_pick,5)
upAndTurnRight()
repeat(move_and_pick,6)
repeat(move_and_pick,5)
one_carrot_only()
turn_left()
turn_left()
repeat(move_and_put,6)
one_carrot_only()
repeat(move_and_put,5)
downAndTurnRight()
one_carrot_only()
repeat(move_and_put,6)
one_carrot_only()
repeat(move_and_put,5)
downAndTurnRight()
one_carrot_only()
repeat(move_and_put,6)
one_carrot_only()
repeat(move_and_put,5)
turn_off()
1.4. Amazing Part 1 ¶
- amazing1.wld ์๋ ํ์ผ์ ์ฐ๋ค.
- ํ์ฌ ์๋๋ฅผ ํ๋ฐ๊ท ๋๋ ๋ก์ง์ ๋ง๋ ๋ค.
{{{~cpp
put_beeper()
while not next_to_a_beeper():
if front_is_clear():
move()
else:
turn_left()
turn_off()
== Amazing Part 2 ==
* amazing2.wld ์๋ ํ์ผ์ ์ฐ๋ค.
* ํ์ฌ ์๋๋ฅผ ํ๋ฐ๊ท ๋๋ ๋ก์ง์ ๋ง๋ ๋ค.
{{{~cpp
def turn_right():
repeat(turn_left, 3)
put_beeper()
move()
while not next_to_a_beeper():
if right_is_clear():
turn_right()
move()
elif front_is_clear():
move()
else:
turn_left()
turn_off()
}}}
== Amazing Part 3,4 ==
* amazing3.wld ์๋ ํ์ผ์ ์ฐ๋ค.
* ํ์ฌ ์๋๋ฅผ ํ๋ฐ๊ท ๋๋ ๋ก์ง์ ๋ง๋ ๋ค.
{{{~cpp
def turn_right():
repeat(turn_left,3)
put_beeper()
if front_is_clear():
move()
else:
turn_left()
if front_is_clear():
move()
else:
turn_left()
move()
while not next_to_a_beeper():
if front_is_clear():
if right_is_clear():
turn_right()
move()
else:
move()
else:
turn_left()
turn_off()
}}}
== Amazing Part 5 ==
* amazing5.wld ์๋ ํ์ผ์ ์ฐ๋ค.
* ํ์ฌ ์๋๋ฅผ ํ๋ฐ๊ท ๋๋ ๋ก์ง์ ๋ง๋ ๋ค.
{{{~cpp
def turn_right():
repeat(turn_left,3)
if front_is_clear():
move()
else:
turn_left()
if front_is_clear():
move()
else:
turn_left()
move()
while not next_to_a_beeper():
if right_is_clear():
turn_right()
move()
elif front_is_clear():
move()
else:
turn_left()
turn_off()
}}}
== ์ด์ ๋ง๋ amazing์ ์จ๋จน์ด ๋ณด์ ==
* hurdle3.wld ์๋ ํ์ผ์ ์ด์ด์ ๋๋ ค๋ณด์.(์ฒ์์ put_beeper()๋ ๋นผ์ผํจ)
* maze1.wld ์๋ ํ์ผ์ ์ด์ด์ ๋๋ ค๋ณด์.
* amazing์ ํด๋ณด๋ฉด์ ๋๋์ ์ ๊ฐ์ ์ด์ผ๊ธฐ ํด๋ด
์๋ค~!
== rain1 ==
* rain1.wld ์๋ ํ์ผ์ ์ฐ๋ค.
* ์ฒ์ ์์ํ ์ฐฝ๋ฌธ ๋ง๊ณ ๋๋จธ์ง ์ฐฝ๋ฌธ๋ค์ beeper๋ฅผ ์์ ๋๋ ์์ผ๋ก ํด์ ๋ซ๋๋ค. ๋ก๋ด์ ์ฒ์ ์์ํ๋ ์ฐฝ๋ฌธ์ผ๋ก ์จ๋ค์์ ๊ทธ ์ฐฝ๋ฌธ์ ๋ฐ๋ผ๋ณด์์ผ ํ๋ค. ์์์์ ๋ก๋ด์ beeper๋ฅผ ์ถฉ๋ถํ ๊ฐ์ง๊ณ ์๋ค.
{{{~cpp
def turn_right():
repeat(turn_left,3)
move()
put_beeper()
turn_left()
move()
def close_window():
if not front_is_clear():
turn_right()
elif left_is_clear():
put_beeper()
move()
else:
move()
def turn_around():
while not next_to_a_beeper():
close_window()
pick_beeper()
turn_left()
turn_around()
turn_off()
}}}
== rain2 ==
* rain2.wld ์๋ ํ์ผ์ ์ฐ๋ค. rain1๊ณผ ์ข ๋ค๋ฅด๊ฒ ์๊ฒผ๋ค.
* rain1์ ์ฝ๋๋ฅผ ์ฌ๊ธฐ์๋ ๋์๊ฐ๋๋ก ๋ง๋ ๋ค.
{{{~cpp
def turn_right():
repeat(turn_left,3)
def turn_back():
repeat(turn_left,2)
move()
put_beeper()
turn_left()
move()
def close_window():
if not front_is_clear():
turn_right()
elif left_is_clear():
put_beeper()
move()
if left_is_clear():
turn_back()
move()
pick_beeper()
turn_right()
move()
else:
move()
def turn_around():
while not next_to_a_beeper():
close_window()
pick_beeper()
turn_left()
turn_around()
turn_off()
}}}
== trash1 ==
* trash1.wld ์๋ ํ์ผ์ ์ฐ๋ค.
* ์ฌ๊ธฐ ์๋ beeper๋ค์ ๋ชจ๋ ๋ชจ์๊ฐ์ง๊ณ ์ผ์ชฝ ์ ๊ตฌ์์ ๋ชจ๋ ๋ชจ์๋ค.๋ค ๋ชจ์ํ ์์ํ ๋์ ์์น์์ ๊ทธ ์์ธ๋ก ์๋๋ค.
{{{~cpp
def turn_back():
repeat(turn_left,2)
def turn_right():
repeat(turn_left,3)
def go_to_garbage():
turn_back()
while front_is_clear():
move()
turn_right()
move()
put_beeper()
turn_back()
move()
turn_left()
while front_is_clear():
move()
if next_to_a_beeper():
pick_beeper()
go_to_garbage()
turn_back()
while front_is_clear():
move()
turn_back()
turn_off()
}}}
== trash2 ==
* trash2.wld ํ์ผ์ ์ฐ๋ค. trash1์์ ์์ฑํ ๋ก์ง์ด ์ฌ๊ธฐ์๋ ๋์๊ฐ์ผ ํ๋ค.
----
[RUR-PLE]









