running example of Ghosts and words: pac-mans represented by yellow number eats food, or encounter ghost names and die

Ghost and words is a continuation from Evolutionary Pac-Man. It uses the same strategy of breaking down words (in this case, using paragraphs from Wikipedia's Pac-Man page) as "food", and also having "poison" or "ghost" that can kill the pac-mans.

Didn't know those ghosts have names...

The initial idea was simple - I wanted the words to act and animate as vectors. It also seemed interesting to use the correlation between actual meanings of words through such method like Word2vec, but I got stuck and spent too much time on other parts and didn't really get to that level.

Evolutionary Pac-Man was revisited because it was already using one unique way of converting text into many vector points. The renewed version more specifically focuses on typographic aspects, by turning (almost) every element into text.

In this game, texts do many things. They get eaten, run away or run towards, or sometimes get killed or starve to death.

process

The "ghosts" and "food" were initially built as classes:

class Ghost {
  constructor(x,y){
    this.x = x;
    this.y = y;
    this.type = ["BLINKY","PINKY","INKY","CLYDE"];
    this.color = ["red", "pink", "cyan", "orange"];
    this.call = int(random(4))
  }

  show(){
    textAlign(CENTER, CENTER);
    fill(this.color[this.call])
    textSize(16);
    text(this.type[this.call], this.x + random(3), this.y + random(3));
  }
}

However, as I start inserting pac-man object, I realized in order to use p5.Vector functions such as p5.Vector.dist, I had to keep them as p5 Vectors:

    for (let i = list.length - 1; i >= 0; i--) {
      // Calculate distance
      let d = p5.Vector.dist(list[i], this.position);
      // If it's within perception radius and closer than pervious
      if (d < this.dna[2 + index] && d < closestD) {
        closestD = d;
        // Save it
        closest = list[i];

So at this point, it's ran with four different arrays of ghost, which I think is bit redundant and I would like to make it simpler in the future.