cp2025 計算機程式

  • Home
    • SMap
    • reveal
    • blog
  • About
    • cs101
    • Computer
      • llama
      • nginx
    • AI
      • QandA
      • Teams
    • Homework
  • Topics
    • Git
      • Git_ex1
      • Git_ex2
    • Python
      • SE
      • CL
      • Loops
      • Recursion
      • SA
      • SST
      • Maze
      • Collect
      • GT
      • Python_ex1
    • Javascript
      • HTML and CSS
    • Project
      • Waitress
      • API
  • Brython
    • Brython_ex
    • Robot_ex
  • Ref
    • Reeborg
      • ex1
      • Otto_ninja
    • tkinter
    • Pyodide
    • Pyodide_ex
    • Pyodide2
      • robot.py
      • Example2
    • Pyodide3
      • png_files
      • Harvest
Reeborg << Previous Next >> Otto_ninja

ex1

https://mde.tw/cp2025/reeborg?lang=en&mode=python&menu=worlds/menus/select_collection_en.json&name=Alone&url=worlds/tutorial_en/harvest1.json&editor=python/harvest1.py 是已知的機器人採收紅蘿蔔的程式,經由以下與 Copilot 的對話,希望透過 Python Class 的編寫解決特定範圍農作物採收的程式。

問句:

以下是 Reeborg 一個用來採收紅蘿蔔的程式, 目前位於 (3,3) 到 (8,8) 的區域中各座標點, 各有一個紅羅蔔等待採收, 現在想要建立一個 harvest() class, 可以利用 (3,3), (8,8)作為標定有農作物必須採收的兩個區域對角點座標, 而程式可以利用此一 harvest 類別生成案例完成採收的任務: def turn(int):
    for i in range(int):
        turn_left()
        
def new_move(int):
    for i in range(int):
        move()
        
def harvest_one_row():
    while object_here():
        take()
    else:
        move()
# move to the field
new_move(2)
turn_left()
new_move(2)

for i in range(3):
    while is_facing_north():
        for i in range(6):
            harvest_one_row()
        for i in range(2):
            turn(3)
            move() 
    else:
        for i in range(6):
            harvest_one_row()
        for i in range(2):
            turn_left()
            move()

AI 回答: https://mde.tw/cp2025/reeborg?lang=en&mode=python&menu=worlds/menus/select_collection_en.json&name=Alone&url=worlds/tutorial_en/harvest1.json&editor=python/harvest1_class_ex1.py 

進一步要求:

請在類別中加上一個採收方向的參數, 內建變數是 horizontal 採收, 也就是由西邊往東邊的水平方向進行採收, 但若該方向變數設為 vertical 則會由南邊往北的所謂垂直方向進行採收

AI 回應: https://mde.tw/cp2025/reeborg?lang=en&mode=python&menu=worlds/menus/select_collection_en.json&name=Alone&url=worlds/tutorial_en/harvest1.json&editor=python/harvest1_class_ex2.py  

延伸到採收 harvest2 農田: https://mde.tw/cp2025/reeborg/?lang=en&mode=python&menu=worlds/menus/select_collection_en.json&name=Alone&url=worlds/tutorial_en/harvest2.json&editor=python/harvest1_class_ex1.py 

但卻沒能套用到 harvest3 農田: https://mde.tw/cp2025/reeborg/?lang=en&mode=python&menu=worlds/menus/select_collection_en.json&name=Alone&url=worlds/tutorial_en/harvest3.json&editor=python/harvest1_class_ex1.py 

而必須要在每一個座標點留下或放入一個紅蘿蔔: https://mde.tw/cp2025/reeborg/?lang=en&mode=python&menu=worlds/menus/select_collection_en.json&name=Alone&url=worlds/tutorial_en/harvest3.json&editor=python/harvest1_class_ex3.py  


Reeborg << Previous Next >> Otto_ninja

Copyright © All rights reserved | This template is made with by Colorlib