Assignment 11

Concept

The project simulates a cellular automaton inspired by systems like Conway’s Game of Life, where cells in a grid evolve based on interactions with their neighbors. The interactive interface enables users to experiment with custom rules, toggle cells’ states, and observe dynamic patterns as the simulation progresses. This tool bridges computational art and mathematics, creating a visually engaging environment where users can explore emergent behaviors.

Highlight I’m proud of
createSpan('<b><br>Grow');
grow = createSelect();
for (let i = 0; i <= 8; i++) grow.option(i);
grow.value(2);

createSpan('<b><br>Underpopulate');
underpop = createSelect();
for (let i = 1; i <= 7; i++) underpop.option(i);
underpop.value(4);

createSpan('<b><br>Overpopulate');
overpop = createSelect();
for (let i = 2; i <= 8; i++) overpop.option(i);
overpop.value(5);
  • Grow: Minimum neighbors needed for a cell to come alive.
  • Underpopulate: Minimum neighbors needed for a cell to stay alive.
  • Overpopulate: Maximum neighbors allowed before a cell dies.

 

  • Choose unique colors for alive cells, enabling personalized designs and aesthetics.

 

  • Use intuitive mouse interactions to toggle cells directly, making the system user-friendly.
    function mousePressed() {
      let w = (width / cellSize);
      let x = floor(mouseX / cellSize);
      let y = floor(mouseY / cellSize);
      let n = x + y * w;
      if (cells[n] != null) {
        eraseMode = cells[n].alive; // Determines if the user is erasing or drawing
      }
    }
    
    function draw() {
      if (mouseIsPressed) {
        let w = (width / cellSize);
        let x = floor(mouseX / cellSize);
        let y = floor(mouseY / cellSize);
        let n = x + y * w;
        if (cells[n] != null) {
          cells[n].alive = !eraseMode; // Toggles the state of the cell
        }
      }
    }
    

     

Embedded sketch


Edit Sketch: https://editor.p5js.org/mariamalkhoori/sketches/uPT54nwAo

Reflection and ideas for future work or improvements
  • Allow users to draw predefined shapes (e.g., gliders or oscillators) directly onto the grid.
  • Implement a zoom/pan feature for exploring large grids in greater detail.
  • Create a timeline or “playback” feature that lets users view how the grid evolved over time.

Leave a Reply

Your email address will not be published. Required fields are marked *