top of page

Exploring the magic and limitations of ChatGPT in generating Python code for acoustic design - Day 3

  • Su
  • Apr 25, 2023
  • 2 min read

Finding rays reflected from a reflector and energy distribution of the reflected rays on the audience plane

On Day 1, ChatGPT effortlessly created an omni-directional source. However, Day 2 proved to be challenging for ChatGPT to achieve the task of generating incident rays to a reflector and finding energy distribution on the reflector. Its code was riddled with errors, causing frustration and forcing me to rewrite it entirely.


Reflecting on the experience, I realised that I was misled by those extraordinary claims online about how ChatGPT could work magic without much human intervention. While it may be true in certain applications, it is not the case for Grasshopper Python.


ChatGPT struggles with the syntax of functions and methods in Python for Rhino Grasshopper. I found that it sometimes makes up syntax and confuses the syntax of similar functions. Additionally, it has difficulty mastering the data types of parameters. However, it generally knows which functions should be used for certain tasks. The logic and structure of the code are often excellent, which is an odd phenomenon. I expected the former to be easier for a machine to understand. It seems that ChatGPT has learned logic and structure from computer programming in general but lacks specific training in Grasshopper Python.


After understanding the strengths and weaknesses of ChatGPT and viewing it as a useful tool rather than a magic wizard, I began to appreciate its power again. For someone not familiar with Grasshopper Python, it provided a map for the task at hand, making the learning process more manageable.


The code below was generated by ChatGPT 4 for generating reflections from a reflector. Despite having only a few lines, the code is not executable. However, it provides the correct procedure: finding the normal vector of a brep using BrepClosestPoint and then using the Rhino.Geometry.Mirror function to create the reflection line.


With the assistance of ChatGPT, I was able to achieve the desired results - an image displaying the energy distribution of reflected rays from the reflector in the audience plane shown on the cover.


Comments


bottom of page