Week 1: Reading Response

In this week’s reading “The Computational Beauty of Nature”, I came across many scientific analogies that have widened my views on nature. Before this reading, I would always look at things from a further perspective and not really think deeply of every object around me and its particular details. Just like the author mentions, the roles of ants in every ant colony would usually be similar, but every ant is unique to its identity and behaves differently despite working on the same task.

It is very fascinating that the reductionist approach can be applied in the computing world. We have had many simulations built thus far that researchers and scientists have benefited from.

Week 1: Self-Avoiding Walk through RGB space

For this week’s assignment, I decided to create a self-avoiding walk within an RGB space.

Whenever a dot tries to walk to a spot that has already been visited before, it stops the program. This can be restarted on click.

In the draw function, I made the RGB space using map() and assigning each dot to a random RGB value.

I tried to simplify the code as much as possible. In the snippet below, it checks if a spot in the grid has been visited before, if not, it pushes a new dot.

for (let option of allOptions) {
  let newX = x + option.dx;
  let newY = y + option.dy;
  if (newX >= 0 && newX < cols && newY >= 0 && newY < rows && !grid[newX][newY]) {
    options.push(option);
  }
}