[[TableOfContents]] * ì¤€ë¹„ìž : 01 ê¹€ìƒì„, 04 문보창 * ì¼ì‹œ : ìˆ˜ìš”ì¼ = 시간 배분 = * ì´ ì†Œìš” ì˜ˆìƒ ì‹œê°„ : 2시간 * 간단한 설명 10분 * 로봇 사용법 20분 * 스테ì´ì§€ 15분마다(6단계) * 힌트, ì„¤ëª…ì€ ê³„ì† ì œê³µ = RUR-PLE ì´ëž€ ? = * í”„ë¡œê·¸ëž˜ë° ì–¸ì–´ë¥¼ ë°°ìš°ëŠ”ê²ƒì€ ìž¬ë°Œì–´ì•¼ 한다는 취지ì—ì„œ 만들어진 환경ì´ë‹¤. ì‹¤ì œë¡œ í•´ë³´ë©´ 재밌다. ë„ì›€ë„ ë§Žì´ ëœë‹¤. * Python 언어를 사용하여 컴퓨터 í”„ë¡œê·¸ëž˜ë° ì–¸ì–´ë¥¼ 배울수 있는 환경ì´ë‹¤. * Python 문법 기반ì´ì§€ë§Œ, 몰ë¼ë„ ìƒê´€ì—†ë‹¤. 주어진 í•¨ìˆ˜ë“¤ì„ ê°€ì§€ê³ í•´ê²°í•´ 나가기 때문ì´ë‹¤. ë³€ìˆ˜ë„ ì•ˆì“´ë‹¤. -_- * ì‹¤ì œë¡œ ë¡œë´‡ì— í”„ë¡œê·¸ëž˜ë° í•´ì„œ ê·¸ ë¡œë´‡ì´ í˜„ì‹¤ì—ì„œ ìžì‹ ì´ í”„ë¡œê·¸ëž˜ë° í•˜ëŠ”ë°ë¡œ 움ì§ì´ëŠ”ê²ƒì„ ë³´ë©´ ì •ë§ ì¢‹ê² ì§€ë§Œ ì—¬ê±´ì´ ì•ˆë˜ëŠ” ë§Œí¼ -_-; 화면으로나마 ê·¸ ë¡œë´‡ì´ ì›€ì§ì´ëŠ” ê²ƒì„ ë³´ë©´ì„œ í”„ë¡œê·¸ëž˜ë° í•´ë³¼ 수 있다. 여기ì—ì„œ 작성하는 ì½”ë“œë“¤ì´ ë¬´ìŠ¨ 쓸모가 있ì„까 ì‹¶ê¸°ë„ í•˜ê² ì§€ë§Œ, ì¶”í›„ì— ì‹¤ì œ ë¡œë´‡ì˜ ë™ìž‘ì„ í”„ë¡œê·¸ëž˜ë°í•´ì„œ 넣는다면 여기서 ì“°ì´ëŠ” ë°©ì‹ê³¼ 비슷하게 ë„£ì„것ì´ë‹¤.(하드웨어ì 으로 ë³µìž¡í•œê²ƒì„ ëª…ë ¹ì–´ë¡œ 추ìƒí™” 시킨다ìŒì— ê·¸ ëª…ë ¹ì–´ì„ ì ì ˆí•˜ê²Œ 복합ì 으로 사용하여 ì›í•˜ëŠ” í–‰ë™ì„ ë¡œë´‡ì´ í•˜ê²Œ 만드는 ì‹ìœ¼ë¡œ..) 즉 ë§ê·¸ëŒ€ë¡œ 로봇 프로그래ë°ì„ ê°„ì ‘ì 으로나 í•´ë³¼ 수 있다. = 규칙들 = == 규칙 1 == * 컴퓨터 프로그래ë°ì„ ìµížˆëŠ” ê²ƒì€ ì•…ê¸°ë¥¼ ìµížˆëŠ” 것과 비슷하다. ë‹¹ì‹ ì€ ê·¸ê²ƒì— ê´€í•´ 단순히 ì½ê¸° ë§ê³ í•´ë´ì•¼ 한다. == 규칙 2 == * ì‚¬ëžŒë“¤ì´ ì½ê¸° 쉬운 í”„ë¡œê·¸ëž¨ì„ ìž‘ì„±í•´ì•¼ 한다. == 규칙 3 == * 컴퓨터 í”„ë¡œê·¸ëž¨ì„ ìž‘ì„±í• ë•ŒëŠ” ë°˜ë³µì„ í•˜ì§€ 마ë¼. = 간단한 러플 사용법 = == 로봇 한번 움ì§ì—¬ 볼까? == * ì°½ì—ì„œ Robot: Code and Learn íƒì„ ì„ íƒí•œë‹¤. * 왼쪽 코드 쓰는 í™”ë©´ì— ì•„ëž˜ì™€ ê°™ì€ ì½”ë“œë¥¼ 넣어 본다. {{{~cpp move() turn_off() }}} * 그후 í™”ë©´ì— Mp3 Play 버튼 비슷하게 ìƒê¸´ ë²„íŠ¼ì„ í´ë¦í•œë‹¤. * ì €ìž¥í•˜ë¼ëŠ” ì°½ì´ ë‚˜ì˜¤ë©´ test ë¼ê³ ë„£ê³ ì €ìž¥í•œë‹¤. * ê·¸ë¦¬ê³ ë‹¤ì‹œ play ë²„íŠ¼ì„ ëˆ„ë¥¸ë‹¤. === 키보드로 로봇 움ì§ì´ê¸° === * í™”ë©´ì˜ ë¡œë´‡ì„ í´ë¦í•œë‹¤. * 왼쪽 ë°©í–¥ 키보드를 누르면 ë°©í–¥ì´ ë°”ë€ë‹¤. * 위쪽 ë°©í–¥ 키보드를 누르면 앞으로 ì´ë™í•œë‹¤. == 왼쪽으로 함 ëŒì•„ 볼까? == * 아래와 ê°™ì€ ì½”ë“œë¥¼ 넣어 본다. {{{~cpp move() turn_left() move() turn_off() }}} * 한칸 앞으로 간다ìŒì— 왼쪽으로 ëŒê³ 나서 한칸 앞으로 ê°€ê³ ë‚˜ì„œ ì •ì§€í•˜ëŠ”ê²ƒì„ ë³¼ 수 있다. === 연습 === * ë¡œë´‡ì´ ê¸¸ì´ 2ì¸ ì‚¬ê°í˜•ì„ 그리면서 반시계 방향으로 ë„ëŠ”ê²ƒì„ ë§Œë“¤ì–´ ë³´ìž. http://rur-ple.sourceforge.net/images/left_square2.png * ë¡œë´‡ì´ ì•„ëž˜ 그림과 ê°™ì´ ì›€ì§ì´ê²Œ 해본다. http://rur-ple.sourceforge.net/images/back_home_start.png http://rur-ple.sourceforge.net/images/back_home.png == ì‚ì‚(beeper) 옮기기 == * beeper를 옮겨 ë³´ìž. * beeper를 드는 ëª…ë ¹ì–´ : pick_beeper() * beeper를 ë‚´ë ¤ 놓는 ëª…ë ¹ì–´ : put_beeper() * beepers1.wld 파ì¼ì„ 연다. * 아래 그림과 ê°™ì´ í•˜ëŠ” 코드를 짜본다. http://rur-ple.sourceforge.net/images/beeper1.png http://rur-ple.sourceforge.net/images/beeper2.png == 디버깅 방법? == * RUR-PLEì—ì„œë„ ë””ë²„ê¹…ì„ í•œë‹¤. * Play버튼 ì˜†ì— Play 모양과 작대기 하나 ìžˆëŠ”ê²ƒì€ step into와 비슷한 ì—í• ì„ í•œë‹¤. ëª…ë ¹ì–´ê°€ 하나씩 실행ëœë‹¤. 현재 실행ë˜ê³ 있는 ëª…ë ¹ì–´ëŠ” 코드 부분ì—ì„œ 회색으로 highlighting ëœë‹¤. * Playë²„íŠ¼ì„ í´ë¦í•˜ê³ 나서 ë¡œë´‡ì´ ì›€ì§ì´ê³ 있는 ë„ì¤‘ì— ìžì‹ ì´ ì›í•˜ëŠ” ìˆœê°„ì— step into 버튼(play 버튼 ì˜†ì— ìžˆëŠ”)ì„ í´ë¦í•˜ë©´ ê·¸ 순간부터 ëª…ë ¹ì–´ê°€ 하나 하나씩 실행ëœë‹¤. * step into ì˜†ì— ìžˆëŠ” ë²„íŠ¼ì€ ì¼ì‹œ 중지 버튼 * ê·¸ ì˜†ì— ìžˆëŠ” 빨간 ë²„íŠ¼ì€ ì™„ì „ 종료 버튼 == ë²½ 만들어 ë³´ìž~! == * 버튼들 중ì—ì„œ ë²½ 처럼 ìƒê¸´ ë²„íŠ¼ì„ í´ë¦í•œë‹¤. 그럼 아래 그림과 ê°™ì€ í™”ë©´ì´ ë‚˜ì˜¨ë‹¤. 여기서 í´ë¦! í´ë¦~! í•´ì„œ ë²½ë“¤ì„ ë§Œë“¤ 수 있다. http://rur-ple.sourceforge.net/images/buildwalls.png === 연습 === * 아래 그림과 ê°™ì´ ë¡œë´‡ì´ ì‹ ë¬¸ë°°ë‹¬ 하게 함 코드를 ìž‘ì„±í•´ë³´ìž http://rur-ple.sourceforge.net/images/newspaper_start.png http://rur-ple.sourceforge.net/images/newspaper_end.png * 아래와 ê°™ì€ ì§€ë„ì—ì„œ 1 모ë‘를 수확하는 코드를 작성해 ë³´ìž. http://rur-ple.sourceforge.net/images/harvest1.png == 중복 피하기 == * 아래와 ê°™ì´ def 를ì¨ì„œ 함수를 ì •ì˜í• 수 있다. http://rur-ple.sourceforge.net/images/turnright_txt.png * repeat ëª…ë ¹ì–´ë¥¼ ì¨ì„œ 여러번 수행해야 하는 함수(ëª…ë ¹ì–´ í¬í•¨)ì„ í•œë²ˆì— ë°©ë³µ 횟수만 ì§€ì •í•´ì„œ ì‚¬ìš©í• ìˆ˜ 있다. {{{~cpp def turn_right(): repeat(turn_left, 3) }}} * ë²½ 만들기 연습ì—ì„œ í•œ ì½”ë“œë“¤ì„ í•¨ìˆ˜í™” í•´ì„œ 중복 ì œê±°ë¥¼ 한다. == if 문 사용 == * next_to_a_beeper() : beeperê°€ 현재 ë¡œë´‡ì˜ ìžë¦¬ì— 있으면 true, 없으면 false를 반환한다. {{{~cpp if next_to_a_beeper(): pick_beeper() }}} * ìœ„ì˜ if문과 함수 ì •ì˜, repeat를 사용하여 아래 화면과 ê°™ì€ ìƒí™©ì„ 처리한다. http://rur-ple.sourceforge.net/images/move_pick_start.png http://rur-ple.sourceforge.net/images/move_pick_end.png === else 문 사용 === * front_is_clear() : ë¡œë´‡ì•žì— ë²½ì´ ì—†ìœ¼ë©´ true, 있으면 false * left_is_clear() : ë¡œë´‡ì˜ ì™¼ìª½ì— ë²½ì´ ìžˆëŠ”ì§€ 검사 * right_is_clear() : ë¡œë´‡ì˜ ì˜¤ë¥¸ìª½ì— ë²½ì´ ìžˆëŠ”ì§€ 검사 * else ë¬¸ì€ ì•„ëž˜ 코드처럼 쓴다. {{{~cpp def move_or_turn(): if front_is_clear(): move() else: turn_left() }}} * 아그래 그림처럼 ë¡œë´‡ì´ ë°©ì•ˆì„ í•œë°”í€´ëŒê²Œ í•´ë³´ìž. ë°© í¬ê¸°ì— ë”°ë¼ì„œ 반복 횟수를 다르게 해줘야 한다. í¬ê¸°ê°€ 5ë¼ë©´ 5*4=20 ì´ëŸ°ì‹ìœ¼ë¡œ.. http://rur-ple.sourceforge.net/images/around1.png == not == * notì€ ì•„ëž˜ì™€ ê°™ì€ ì‹ìœ¼ë¡œ 사용한다. {{{~cpp if not next_to_beeper(): move() else: turn_off() }}} === 연습 === * 아래 그림처럼 ë§Œë“ ë‹¤. http://rur-ple.sourceforge.net/images/harvest4.png http://rur-ple.sourceforge.net/images/harvest1.png * ë¬¸ì œì—ì„œ 아래와 ê°™ì€ ì†ŒìŠ¤ë¥¼ ì°¸ê³ í•˜ë¼ê³ 한다. ì €ëŠ” 좀 다르게 했습니다. ìš°ì„ ì°¸ê³ ëŠ” í–ˆê³ .. {{{~cpp # introducing vocabulary related to the problem next_to_a_carrot = next_to_a_beeper plant_carrot = put_beeper pick_carrot = pick_beeper def one_carrot_only(): if not next_to_a_carrot(): plant_carrot() # replace missing seed else: pick_carrot() if not next_to_a_carrot(): # oops! plant_carrot() # we had removed the only one }}} == while == * 아래와 ê°™ì€ ì‹ìœ¼ë¡œ 사용한다. {{{~cpp next_to_a_carrot = next_to_a_beeper plant_carrot = put_beeper pick_carrot = pick_beeper def one_carrot_only(): while next_to_a_carrot(): pick_carrot() # pick them all! plant_carrot() # replant only one }}} * harvest3.wld 파ì¼ì„ 연다. * whileë¬¸ì„ ì‚¬ìš©í•˜ì—¬ ì¤‘ë³µëœ ì”¨ì•—ì˜ ê°œìˆ˜ê°€ 2 ì´ìƒì¸ ìž„ì˜ì˜ ê°œìˆ˜ì¼ ê²½ìš°ì—ë„ ì²˜ë¦¬ 가능하게 위 소스를 ìˆ˜ì •í•œë‹¤. http://zeropage.org/~namsangboy/rurple.GIF == Amazing Part == * ì •ë§ ìœ ìµí•œ ë‚´ìš©ì´ë‹¤. 주어진 간단한 몇가지 ìƒí™©ì„ 해결하면 놀ë¼ìš´ ê¸°ëŠ¥ì´ ë˜ëŠ”ê²ƒì„ ë³¼ 수 있다. * sorting ë¬¸ì œë¥¼ í’€ê³ ë‚˜ì„œ 시간 ë‚¨ì€ ë¶„ì€ í•´ë³´ì‹œê¸¸. [http://rur-ple.sourceforge.net/en/amazing1.htm 러플 Amazing 설명] == Sorting == * sort0_1.wld 파ì¼ì„ 연다. * 주어진 ì‚ì‚ë“¤ì„ ê·¸ë¦¼ì²˜ëŸ¼ 오름차순으로 ë¡œë´‡ì´ ì •ë ¬í•˜ê²Œ 만들면 ëœë‹¤. * 아래는 간단하게 2ê°œì˜ columnì˜ ê²½ìš° ì •ë ¬í•œ 모습ì´ë‹¤. http://rur-ple.sourceforge.net/images/sort1_start.png http://rur-ple.sourceforge.net/images/sort1_end.png * 다ìŒì€ sort0_2.wld 파ì¼ì„ 연다. * 아래 그림과 ê°™ì´ ì›ëž˜ ì •ë ¬ë˜ì–´ 있는 경우ì—ë„ ì œëŒ€ë¡œ ìž‘ë™ë˜ëŠ”지 테스트 해본다. http://rur-ple.sourceforge.net/images/sort2.png http://rur-ple.sourceforge.net/images/sort2.png * sort1 파ì¼ì„ 연다. * 아래 그림과 ê°™ì´ ì¢€ë” ë³µìž¡í•œ ì—¬ëŸ¬ê°œì˜ column ì—ì„œë„ ìž‘ë™í•´ì•¼ 한다. http://rur-ple.sourceforge.net/images/sort3_start.png http://rur-ple.sourceforge.net/images/sort3_end.png * sort2 는 추후 공개 = 경품 = * sort1, sort2 ë§µì„ ê°€ìž¥ ë¨¼ì € ëª¨ë‘ ì˜¤ë¦„ì°¨ìˆœìœ¼ë¡œ ì •ë ¬í•˜ëŠ” 분ì—게 [ë°ë¸”ìŠ¤ìº í”„/2005/RUR-PLE/경품]ì„ ë“œë¦½ë‹ˆë‹¤. * 05 [조현태] êµ°ì´ ê°€ìž¥ ë¨¼ì € sortingì„ í•´ê²°í•˜ì—¬ ê²½í’ˆì„ íƒ”ìŠµë‹ˆë‹¤. ì´í›„ 01 ê¹€ì •í˜„ ì´ sort2 ë§µì— ëŒ€í•´ì„œ 해결하였지만 sort1ì— ëŒ€í•´ì„œëŠ” 부분ì 으로 해결하였습니다. [ë°ë¸”ìŠ¤ìº í”„2005/RUR_PLE/조현태] = ì°¸ê³ = * [RUR-PLE] * [http://zeropage.org/~namsangboy/RUR_PLE.ppt 피피티 ìžë£Œ] * [http://zeropage.org/~namsangboy/world.zip 지ë„] Upload:ìƒì„.zip ---- [ë°ë¸”ìŠ¤ìº í”„2005]