U E D R , A S I H C RSS

RUR-PLE/Etc

1. RUR-PLE/Etc

  • λŸ¬ν”Œμ˜ λ‚˜λ¨Έμ§€ μ˜ˆμ œλ“€..

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]
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:27:49
Processing time 0.0129 sec