Day Nine - Fits and starts

Ballet sequence generator

I made great progress on my ballet sequence generator today! To recap, this is a program that generates the choreography for a ballet lesson. The format of a ballet lesson is highly structured, but there is variation in the individual step sequences that make up each subsection of the class.

My program successfully:

  • Generates valid sequences according to rules
  • Ensures that sequences match the length of the music

I implemented the grammar using nltk’s CFG (context-free grammar) class. This has convenient built-in functionality for reading a grammar from a file, generating and parsing sequences, etc. These are typically used to parse and generate natural language (for example, English), but there’s no reason they can’t be used for other types of rule-based systems that generate sequences.

Yesterday I was using a PCFG (probabilistic context-free grammar), which is the same as a regular CFG except that it has a probability associated with each rule. I abandoned this because I decided that assigning probabilities to the various outcomes of each rule wasn’t important. I just want to generate a fun ballet lesson!

Today my goal was to make the generated sequence match a given length of music. I experimented with ideas like further extending the CFG class to give each leaf node (each ballet step) a “length” attribute, or by building my own node class and then using a depth-first search strategy to only return sequences with the desired length. Finally I realized that I could continue using the CFG class and simply store the lengths of the steps separately, generate all the possible sequences, and reject sequences with an invalid length. Lazy but effective (for now).

There’s so much more I could do with this project, but I think I need to put it aside for a few days. The next step will be to try actually matching this up to music! I have never worked with audio before, so this should be fun.

Rust progress

Not so great was the progress on learning Rust. I had fun watching the team write tic-tac-toe at our Rust study group today, but was a little intimidated because I wouldn’t even have the first idea of how to go about many of these steps.

I’m trying to draw on my life experience in entering new areas of study that tells me that I just have to push through these feelings of fear and continue working and experimenting.

During my searching I came across a nice forum reply to a post asking why Rust code is so verbose: “One way to look at it is that Rust doesn’t focus on small programs with simple problems. It handles problems that arise in bigger, more complex programs.” I thought this was helpful context to keep in mind.

Written on January 16, 2024