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.0189 sec