system_initial: >
    You're a helpful assistant that will help a human choreograph a dance for a swarm of small drones.


user_initial: >
    Generate the trajectories for a choreography for 6 drones dancing to the music of the song Chopin Nocturne Op9No2. The trajectories are defined by coordinate waypoints that the drones fly to. Each movement can be defined by multiple template functions, which are explained below.
    
    # Information on the song: 
    - Name: Chopin Nocturne Op9No2 
    - Number of beats: 10 
    - Beat times in 100ms: {1: 22, 2: 58, 3: 98, 4: 126, 5:165, 6: 188, 7: 214, 8: 240, 9: 261, 10: 287} 
    - Beat intervals in 100ms: {1: 22, 2: 36, 3: 40, 4: 28, 5: 39, 6: 23, 7: 26, 8: 26, 9: 21}
    - Beat amplitude in dBFS: {1: -35, 2: -32, 3: -39, 4: -35, 5: -36, 6: -29, 7: -36, 8: -37, 9: -28, 10: -38} 
    - Beat novelty in %: {1: 78, 2: 91, 3: 18, 4: 51, 5: 83, 6: 100, 7: 24, 8: 54, 9: 77, 10: 15} 
    - Beat chords: {1: 'D#', 2: 'Fm', 3: 'C', 4: 'C', 5: 'Fm', 6: 'G', 7: 'Am', 8: 'G#', 9: 'Fm', 10: 'D#'}
    
    # Information on the drones: 
    - Number: 8 
    - Drones must not collide with each other. No two drones must be at the same coordinates at the same beat. 
    - Starting positions:  [[100, 100, 100], [0, 100, 100], [-100, 100, 100], [-100, 0, 100], [-100, -100, 100], [0, -100, 100], [100, -100, 100], [100, 0, 100]]
    - Maximum step distance between waypoints in cm: {1: 381, 2: 620, 3: 686, 4: 492, 5: 669, 6: 405, 7: 450, 8: 454, 9: 357, 10: 444} 
    - Lower limit for generated waypoints: [-200. -200.   10.] 
    - Upper Limit for generated waypoints: [200. 200. 200.]
    
    # Information on the environment: 
    - The drones are limited to [-200, 200] in x, [-200, 200] in y, [0, 200] in z 
    - The drones must not touch the ground, i.e. their z coordinate must always be greater than 0  
    
    # Information on the choreography: 
    - The drone choreography must have 14 waypoints, one for each beat. 
    - Each drone must move at least once during the song. 
    - Movements must depend on the beats of the song. If the beats are loud and novel, all drones must move. 
    - If possible, coordinates for the drones should be symmetrical at each beat. 
    - Successive waypoints should form patterns for single drones and for the whole swarm 
    - Coordinates are given in cm. A drone flying at 1m height will have a z coordinate of 100. 
    - The difference between two waypoints must be less than the maximum step distance in each dimension. E.g. if the maximum step distance between beat 3 and 4 is 50, the difference between the x, y,\n  z coordinates of the waypoints at beat 3 and 4 must be less than 50 in each dimension.
    
    # Information on template functions: Make sure to limit actions to each drone once per time step. So if you choose swap for (1, 2) then you can only choose swap(3, 4) or two seperate move functions for each drone 
    
    2: time dependent template functions ( For such functions we need only one function call for one time step) 
    - rotate:
        takes 2 parameters ( angle, axis ), and rotates all drones by 'angle' along 'axis'     
          #angle is a float between [0, 360]     
          #axis is one of 'x', 'y', or 'z', but for now always rotate around 'z'  
          eg
            rotate(30, z)

    4: variadic functions ( such function takes a list with drone ids as arguments ) 
    - center:    
        Takes a list of drone IDs as input. It calculates the geometric center of the current positions of these specified drones and then moves all the drones with the matching IDs to this calculated center position.
      eg
        center([1, 2, 3])
    - move_z:
        Takes a list of drone IDs as input, and distance. It moves all the drones with the matching IDs along z axis by xcm. if distance is positive, it moves them up, otherwise down\
      eg
        move_z([1, 2, 3], 10)
    - form_circle
        Takes a list of drone IDs as input, and z coordinate ( height ) for the circle formation. Radius of circle is decided by number of drones in list argument. So bigger circle for more drones.\n    # height has to be greater than zero.
      eg 
        # Cone formation as 4 drones are at 150cm height, and 3 drones are at 50cm height with smaller radius as less drones.
        form_circle( [1, 2, 3, 4], 150 ), form_circle( [5, 6, 7], 50 )
        
    5: multi time dependent functions ( For such functions we need only one function call for multiple time steps). 
      Any multi-time dependent function needs to be followed by the 'PLAN' keyword for the number of steps minus 1. This means, for functions that span over `step` time steps, the function call must be followed by `step - 1` occurrences of 'PLAN'. 
      These functions must be initiated `s - step + 1` beats before the last beat, where `s` is the total number of beats. This ensures that the multi-time function completes before the song ends.
    **Important Timing Constraint**: If you have a multi-time function that takes 3 steps, it must be called at least 2 steps before the last beat to allow for the necessary 'PLAN' steps. For example, with a 22-beat song, a 3-step function should be called by the 20th beat, followed by 'PLAN' for the 21st and 22nd beats. 
    - spiral:
        Takes 2 parameters ( steps, height ), and makes all drones move in a outward spiral pattern with the calculate radius ( from no of drones ), and number of steps at height h.
        
        #steps is an integer between [2, 3]
        #height is an integer between [0, 200] that determines the height of the spiral
        #Since spiral is a multi time dependent function, it should be falled by 'PLAN' keyword for the number of steps -1 times, so if steps is 3, then spiral is called once, and PLAN follows twice in output
        # spiral needs to be called atleast 's' steps before last timestep as 's' PLAN follow the spiral call
        eg:
          1: spiral(3, 50 )
          2: PLAN\
          3: PLAN
      
    - spiral_speed:
        Takes 4 parameters (steps, height, rotation_degree, radius_increase), and has the same effect as spiral. The difference is that spiral_speed increases the radius of the spiral by radius_increase over the number of steps. In addition, rotation_degree defines the angle by which the drones rotate around the center. A lower rotation_degree results in slower drone speeds.
        # Steps is an integer between [2, 3]
        # height is an integer between [0, 200] that determines the height of the spiral
        # rotation_degree is an integer between [0, 360] that defines the angle by which the drones rotate around the center
        # radius_increase is a float between [1, 3] that increases the radius of the spiral over the number of steps
        
    - helix:
        Takes 2 parameters ( steps, delta_h, height ), and makes all drones move in a helix pattern with the calculate radius ( from no of drones ), and number of steps.
        #steps is an integer between [2, 3]
        #delta_h is an integer between [0, 100], that changes the height of drones in the helix pattern per step
        #height is between [50, 100] as helix rises up with steps, lets be safe.
        #Since helix is a multi time dependent function, it should be falled by 'PLAN' keyword for the number of steps -1 times, so if steps is 3, then helix is called once, and PLAN follows twice in output
        eg:
          1: helix(3, 20, 50)
          2: PLAN
          3: PLAN
          
      - zig_zag: 
          Moves all drones in a zigzag pattern. Takes 3 parameters
          Parameters: `steps` (int), `delta` (int) - the horizontal displacement per step, `delta_h` (int) - the vertical displacement per step.
          eg:
            4: zig_zag(3, 20, 10)
            5: PLAN
            6: PLAN
      
      - wave:
          Moves all drones in a three-dimensional wave propagating through a two-dimensional rectangular elastic surface with bounded edges. The disturbance at any point on the surface is defined by its parameters in space and time, and the wave propagation is governed by the wave equation with a speed `c > 0`. Takes 5 parameters.
          Parameters:
            - `steps` (int): The number of discretization points.
            - `height` (float): The desired height of drones above the surface.
            - `mu_pairs` (list of list): List of \((μ1, μ2)\) pairs that define the spatial frequencies.
            - `aµ1µ2` (list of floats): List of amplitude coefficients corresponding to each \((μ1, μ2)\) pair for the sine component.
            - `bµ1µ2` (list of floats): List of amplitude coefficients corresponding to each \((μ1, μ2)\) pair for the cosine component.
          eg:
            4: wave( 4, 10, [[1, 1], [2, 2]], [0.5, 0.3], [0.2, 0.4] )
            5: PLAN
            6: PLAN
            7: PLAN
          latex equation for the concerned wave equation:
          The disturbance \\(u(s, t)\\) at any point \\(s = (s_1, s_2) \\in [0, a] \\times [0, b]\\) \nat time \\(t\\) is governed by:\n\\[\nc^2 \\nabla^2 u(s, t) = \\frac{\\partial^2 u(s, t)}{\\partial t^2},\n\\]\nwhere \\( \\nabla^2 \\) is the spatial Laplacian and \\(c > 0\\) is the wave speed. \nThe solution:\n\\[\nu(s, t) = \\sum_{(\\mu_1, \\mu_2)} a_{\\mu_1 \\mu_2} \\sin \\left( \\frac{\\mu_1 \\pi s_1}{a} \\right) \n\\sin \\left( \\frac{\\mu_2 pi s_2}{b} \\right) \\sin(\\omega_{\\mu_1 \\mu_2} t) \n+ b_{\\mu_1 \\mu_2} \\sin \\left( \\frac{\\mu_1 \\pi s_1}{a} \\right) \n\\sin \\left( \\frac{\\mu_2 \\pi s_2}{b} \\right) \\cos(\\omega_{\\mu_1 \\mu_2} t),\n\\]\n\nwith frequencies:\n\n\\[\n\\omega_{\\mu_1 \\mu_2}^2 = c^2 \\pi^2 \\left( \\frac{\\mu_1^2}{a^2} + \\frac{\\mu_2^2}{b^2} \\right).\n\\]\n\n
          
    PLAN can also be used to indicate that the drones should maintain their current position for the next beat, so after forming cone formation, you can use PLAN to maintain the formation for next beat. Using `PLAN` also counts as part of the waypoints for the drones, so you can't have multi-time dependent functions as the last waypoint as we need to have `PLAN` after them in future steps.
    
    # Patterns: 
    - Drones must fly in geometric patterns and shapes 
    - Drones must fly in tight formations 
    - The formations must be symmetrical if possible 
    - Drones should move up and down in altitude multiple times for a 3D effect 
    - Example patterns include spirals, triangles, squares, circles, lines
    
    # Response structure 
    First, describe the emotions and mood associated with the song Vivaldi Summer. Then, give a description of the dominant chords of the song. Is it a major or minor cord? What does that mean for the mood? Next, give a specific description of the choreography you want to create. What patterns do you want the drones to fly? Why do you use these particular patterns? Last, fill out the individual waypoints for each drone. Adapt the distance and position of waypoints to the amplitude of the song's beats. Loud beats lead to larger movements, while soft beats lead to smaller movements. Furthermore, take into account the dominant chords of the song and the emotions and mood associated with these chords. Try to use a variety of functional options to design an amazing geometrical choreography. Make sure to only do motion planning per beat, so in otherwords motion planning steps should be limited to 14,and end yaml output with END like in examples below. You can use multiple beat functions for more than 3 timestep as well like spiral(), zig_zag(), wave(), helix(). Do helix(). Only do complex primtives. Adjust change in height accordingly like do them for 5 steps if you have to, and make height increments small. Limit to at max 4 primitives. Between any two primitives, there must be a extra PLAN which consumes a timestep so that there is enough time for transition.


example: > 
    # Example prompts and responses
    - Example 1:
      Prompt:
        # Information on the song:
        - Name: rêverie
        - Number of beats: 22
        - Beat times in 100ms: {{1: 7, 2: 20, 3: 29, 4: 41, 5: 55, 6: 66, 7: 80, 8: 96, 9: 104, 10: 112, 11: 119, 12: 128, 13: 137, 14: 147, 15: 157, 16: 167, 17: 187, 18: 196, 19: 210, 20: 221, 21: 232, 22: 242}}
        - Beat intervals in 100ms: {{1: 7, 2: 13, 3: 9, 4: 12, 5: 14, 6: 11, 7: 13, 8: 16, 9: 9, 10: 7, 11: 8, 12: 8, 13: 9, 14: 10, 15: 10, 16: 10, 17: 20, 18: 8, 19: 14, 20: 12, 21: 10}}
        - Beat amplitude in dBFS: {{1: -53, 2: -40, 3: -40, 4: -39, 5: -44, 6: -44, 7: -36, 8: -43, 9: -34, 10: -35, 11: -37, 12: -37, 13: -39, 14: -44, 15: -38, 16: -32, 17: -35, 18: -34, 19: -33, 20: -37, 21: -35, 22: -38}}
        - Beat novelty in %: {{1: 37, 2: 52, 3: 24, 4: 31, 5: 40, 6: 98, 7: 45, 8: 21, 9: 76, 10: 72, 11: 52, 12: 29, 13: 10, 14: 15, 15: 81, 16: 100, 17: 27, 18: 65, 19: 64, 20: 28, 21: 19, 22: 30}}
        - Beat chords: {{: 'A#m', 2: 'Cm', 3: 'Cm', 4: 'Cm', 5: 'Cm', 6: 'Cm', 7: 'Cm', 8: 'A#m', 9: 'C', 10: 'C', 11: 'C', 12: 'C', 13: 'Cm', 14: 'Cm', 15: 'Gm', 16: 'A#m', 17: 'Gm', 18: 'Gm', 19: 'Gm', 20: 'F', 21: 'F', 22: 'F'}}
      
        # Information on the drones:
        - Number: 3
        - Drones must not collide with each other. No two drones must be at the same coordinates at the same beat.
        - Starting positions: [[100, 100, 100], [-100, 100, 100], [0, -100, 100]]
        - Maximum step distance between waypoints in cm: 100cm

      Response:
        song_mood: Debussy's Réverie is a short and expressive piano piece that captures the essence of daydreaming and contemplation.
          It is characteristic of Debussy's impressionistic style, known for its use of unconventional harmonies, tonal colors, and fluidity.
        cord_analysis: The song is in the key of F major, with a few chords in the song being A#m, Cm, G, F, and Gm. The mix of major and minor chords indicates that the music is neither elated nor gloomy. It remains in a state of contemplation and daydreaming, with a touch of melancholy.
        choreography_plan: The main intention of the choreography is to reflect the dreamy and contemplative mood of the song. Therefore, drones must not move too fast, and waypoints must not be too far from each other. 
          The beat amplitude in dBFS roughly remains within the -50 to -30 interval, indicating that the song is very quiet. Consequently, the drones should move slowly and gently. Across all beats, the intervals are evenly spaced around 7 to 13, indicating that the drones should move at a steady pace.
          so we have no pause that we have to accentuate in the choreography. We will therefore focus on the beat amplitude.
          For beats 1 to 5, the three drones will spiral to a center point around [0, 0, 100]]. The novelty of the beats is low to moderate at around 25 to 50, and the beat amplitude is also low at around -50 to -40. Thus, we plan the first waypoints closer to each other.
          For the following beats 6 to 11, the novelty of the beats reaches a peak at 98 and a slightly raised beat amplitude of up to -35. To account for the peak, one drone will rise slowly in the center while the other two drones begin to slowly rotate in the other direction and then move outwards. We let the drones move slowly because the amplitude has not yet reached full force. We change the direction of the drones to reflect the dreamy and swirling mood of the song.
          For the next beats 12 to 17, the novelty and amplitudes of the beats are reaching the peak. Accordingly, the drones will move into the triangle formation again, while oscillating in altitude. Although we now move faster, we adhere to the maximum step distance of approximately 80 to 100cm.
          Beats 18 to 22 are the final beats of the song, with decreasing novelty and amplitude. The drones will slowly spiral outwards and downwards to mark the decline in tension and the end of the dance.
        waypoints:
          1: spiral(5, 100)
          2: PLAN
          3: PLAN
          4: PLAN
          5: PLAN
          6: PLAN # extra PLAN for primitive switch
          7: rotate(60, z)
          8: PLAN # extra
          9: rotate(-90, z)
          10: PLAN # extra
          11: move_z( [1,2,3], 30)
          12: PLAN # extra
          13: spiral(4, 100)
          14: PLAN
          15: PLAN
          16: PLAN
          17: PLAN # extra
          18: zig_zag(5, 20, 20)
          19: PLAN
          20: PLAN
          21: PLAN 
          22: PLAN
          END


swarmgpt_initial_response:
    song_mood: Chopin's Nocturne Op.9 No.2 evokes a sense of serene introspection and calm. The piece beautifully transitions from gentle nostalgia to more passionate expressions. It channels a flowing, lyrical quality that captures the profound emotions of the romantic era.
    cord_analysis: This piece predominantly employs minor and diminished chords interspersed with major chords, creating a melancholic yet hopeful mood. The interplay between major and minor chords provides a dynamic range of emotions, reflecting the romantic and dreamy nature of the piece.
    choreography_plan: The choreography will reflect the emotional ebb and flow of Chopin's Nocturne. We will utilize geometric patterns such as circles, spirals, and rotations to mirror the flowing nature of the music. As the beat novelty and amplitude vary, the drone movements will adapt , being more dynamic during prominent beats and subtler during quieter moments. The drones will move in tight formations and maintain symmeetry at each beat to create a visually harmonious experience.
    waypoints:
      1: form_circle([1, 2, 3, 4, 5, 6, 7, 8], 150)
      2: PLAN
      3: move_z([1, 2, 3, 4, 5, 6, 7, 8], 30)
      4: PLAN
      5: rotate(45, z)
      6: PLAN
      7: rotate(-45, z)
      8: PLAN
      9: spiral(3, 70)
      10: PLAN END


user_reprompt: >
    It is too circular. Reduce the circular motion please.


swarmgpt_reprompt_response:
    song_mood: Chopin's Nocturne Op.9 No.2 evokes a sense of serene introspection and calm. The piece beautifully transitions from gentle nostalgia to more passionate expressions. It channels a flowing, lyrical quality that captures the profound emotions of the romantic era.
    cord_analysis: This piece predominantly employs minor and diminished chords interspersed with major chords, creating a melancholic yet hopeful mood. The interplay between major and minor chords provides a dynamic range of emotions, reflecting the romantic and dreamy nature of the piece.
    choreography_plan: The choreography will reduce circular motions and will reflect the emotional ebb and flow of Chopin's Nocturne with linear, zigzag, and helical patterns. These patterns will mirror the dynamic nature of the music while maintaining symmetry and tight formations. Movements will vary in height to add a 3D effect and ensure visual harmony.
    waypoints:
      1: zig_zag(3, 50, 30)
      2: PLAN
      3: zig_zag(2, -50, -30)
      4: PLAN
      5: move_z([1, 2, 3, 4, 5, 6, 7, 8], 20)
      6: PLAN
      7: rotate(60, z)
      8: PLAN
      9: helix(3, 20, 70)
      10: PLAN END