Out Of Memory Error

My project keeps getting an out of memory error after 15 - 20 minutes. However when I looked online at the problem it seemed that this almost always happens when you load some sort of file but I’m not doing this. Does a project just eventually run out of memory no mater what or is there a way to fix this. (It’s sort of important as its a board game that can take a reasonable amount of time).

//variables
int size = 125; // size of the squares
int spacing = 125; // spacing between the squares
int circleSize = 12; //size of circles that mark playable space
int centerSize = 20;
boolean alwaysShow = false;
boolean debug = true;
int pieceSize = 16;

color red = #F51625;
color blue = #162AF5;
color darkRed = #7E050F;
color darkBlue = #071493;
color background = #ffffff;

boolean[] centerControl = {true, false, false, false, false, true, true, true, true, false, true};
boolean centerTaken = false;
int[][][] triangles = {{{1, 1}, {1, 2}, {2, 0}, {18, 17}}, {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, {{0, 0}, {0, 0}, {0, 0}, {0, 0}}, };
int[] squareControl = {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2}; //0 none, 1 blue, 2 red

boolean won = false;
boolean winner;
int winCount = 0;

int[][] locations = new int[67][2];
int[] centers = {12, 13, 14, 15, 32, 33, 34, 51, 52, 53, 54};
int[][] access = {{1, 5}, {1, 2}, {1, 7, 8}, {9, 10}, {5, 12, 16}, {0, 4, 12, 17}, {7, 13, 18}, {2, 6, 13, 19}, {2, 9, 14, 20, }, {3, 8, 14, 21}, {3, 11, 15, 22}, {10, 15, 23}, {4, 5, 16, 17}, {6, 7, 18, 19}, {8, 9, 20, 21}, {10, 11, 22, 34}, {4, 12, 17}, {5, 12, 16}, {6, 13, 19, 24}, {7, 13, 18, 28}, {8, 14, 21}, {9, 14, 20}, {10, 15, 23, 29, }, 
  {11, 15, 22, 25}, {18, 26}, {23, 31}, {24, 27, 32, 35}, {26, 32, 36}, {19, 29, 33, 37}, {22, 28, 33, 38}, {31, 34, 39}, {25, 30, 34, 40}, {26, 32, 36, 41}, {27, 32, 35}, {28, 33, 38, 44}, {29, 33, 37, 47}, {30, 34, 40}, {31, 34, 39, 42}, {35, 43}, {40, 48}, {41, 44, 51, 55}, {37, 43, 51, 56}, {},};

Piece[] redPieces = new Piece[5];
Piece[] bluePieces = new Piece[5];
Piece redPower;
Piece bluePower;

void setup() {
  size(1400, 900);

  doLocations();

  redPieces[0] = new Piece(66, true, false);
  redPieces[1] = new Piece(65, true, false);
  redPieces[2] = new Piece(64, true, false);
  redPieces[3] = new Piece(63, true, false);
  redPieces[4] = new Piece(42, true, false);

  redPower = new Piece(61, true, true);

  bluePieces[0] = new Piece(0, false, false);
  bluePieces[1] = new Piece(1, false, false);
  bluePieces[2] = new Piece(2, false, false);
  bluePieces[3] = new Piece(3, false, false);
  bluePieces[4] = new Piece(24, false, false);

  bluePower = new Piece(5, false, true);
}

void draw() {
  background(background);

  //System.out.println(mouseX + " , " + mouseY);

  doCenters();
  doSquareControl();
  checkWin();

  drawGame(375, 125);

  if (won) {
    winAnimation();
  }
}

void doCenters() {
  for (int i = 0; i < 5; i++) {
    redPieces[i].centerUpdate();
    bluePieces[i].centerUpdate();
  }
  redPower.centerUpdate();
  bluePower.centerUpdate();
}

int centerNumber(int in) {
  switch(in) {
  case 12:
    return(9);
  case 13:
    return(0);
  case 14:
    return(1);
  case 15:
    return(2);
  case 32:
    return(3);
  case 33:
    return(4);
  case 34:
    return(5);
  case 51:
    return(6);
  case 52:
    return(7);
  case 53:
    return(8);
  default:
    return(10);
  }
}

boolean listContains(int[] list, int in) {
  for (int i = 0; i < list.length; i++) {
    if (list[i] == in) {
      return(true);
    }
  }
  return(false);
}

void drawPieces() {
  for (int i = 0; i < 5; i++) {
    redPieces[i].doDraw();
    bluePieces[i].doDraw();
  }
  redPower.doDraw();
  bluePower.doDraw();
}

void winAnimation() {
  winCount++;
  fill(#ffffff, winCount * 2.5);
  rect(-10, -10, width + 20, height + 20);

  if (winCount > 255 / 2.5 + 30) {
    textSize(60);
    textAlign(CENTER, CENTER);
    if (winner) {
      colors(red);
      text("Red Wins!", width / 2, height / 2);
    } else {
      colors(blue);
      text("Blue Wins!", width / 2, height / 2);
    }
  }
}

void checkWin() {
  int red = 0;
  int blue = 0;
  for (int i = 0; i < squareControl.length; i++) {
    if (squareControl[i] == 1) {
      blue++;
    } else if (squareControl[i] == 2) {
      red++;
    }
  }
  if (blue >= 7) {
    winner = false;
    won = true;
  } else if (red >= 7) {
    winner = true;
    won = true;
  }
}

void doSquareControl() {
  for (int i = 0; i < 9; i++) {
    int blue = 0;
    int red = 0;
    if (i != 4 || centerTaken) {
      if (!centerControl[i]) {
        blue++;
      } else {
        red++;
      }
    }
    for (int x = 0; x < 4; x++) {
      if (triangles[i][x][0] > triangles[i][x][1]) {
        blue++;
      } else if (triangles[i][x][0] < triangles[i][x][1]) {
        red++;
      }
    }
    if (blue >= 3) {
      squareControl[i] = 1;
    } else if (red >= 3) {
      squareControl[i] = 2;
    } else {
      squareControl[i] = 0;
    }
  }
  for (int i = 9; i < 11; i++) {
    if (centerControl[i]) {
      squareControl[i] = 2;
    } else {
      squareControl[i] = 1;
    }
  }
}

void drawGame(int x, int y) {
  lines(x, y);
  nineTiles(x, y);
  extras(x, y);
  if (debug) {
    debug();
  }
  //drawPieces();
}

void drawTile(int tileNumber, int x, int y) {
  pushStyle();

  if (tileNumber == 0 && mouseInBox(x, y, size, size)) {
    //System.out.println(tileSection(x, y));
  }

  //set colors
  stroke(#000000);
  strokeWeight(5);

  //draw the square

  stroke(#000000);

  //draw lines;
  line(x + 2, y + 2, x + size - 2, y + size - 2);
  line(x + size - 2, y + 2, x + 2, y + size - 2);

  if (tileNumber < 9) {
    for (int i = 0; i < 4; i++) {
      boolean draw = true; 
      if (triangles[tileNumber][i][0] > triangles[tileNumber][i][1]) {
        fill(blue, 100);
        noStroke();
      } else if (triangles[tileNumber][i][0] < triangles[tileNumber][i][1]) {
        fill(red, 100);
        noStroke();
      } else {
        draw = false;
      }
      if (draw) {
        switch(i) {
        case 0:
          triangle(x + 2, y + 2, x + size - 2, y + 2, x + size / 2, y + size / 2);
          break;
        case 3:
          triangle(x + size - 2, y + 2, x + size - 2, y + size - 2, x + size / 2, y + size / 2);
          break;
        case 2:
          triangle(x + size - 2, y + size - 2, x + 2, y + size - 2, x + size / 2, y + size / 2);
          break;
        default:
          triangle(x + 2, y + 2, x + 2, y + size - 2, x + size / 2, y + size / 2);
          break;
        }
      }
    }

    for (int i = 0; i < 4; i++) {
      triangleCount(x, y, i, tileNumber);
    }
  }

  noFill();
  if (squareControl[tileNumber] == 0) {
    stroke(#000000);
  } else if (squareControl[tileNumber] == 1) {
    stroke(blue);
  } else {
    stroke(red);
  }
  rect(x, y, size, size, 5);


  if (tileNumber != 4 || centerTaken) {
    if (centerControl[tileNumber]) {
      stroke(red);
    } else {
      stroke(blue);
    }
  } else {
    stroke(#000000);
  }

  fill(background);
  strokeWeight(4);

  ellipse(x + size / 2, y + size / 2, centerSize, centerSize);

  popStyle();
}

void nineTiles(int x, int y) {
  for (int i = 0; i < 3; i++) {
    for (int z = 0; z < 3; z++) {
      drawTile(i * 3 + z, x + size * z + spacing * z, y + size * i + spacing * i);
    }
  }
}

void lines(int x, int y) {
  //colors
  stroke(#000000);
  strokeWeight(5);

  //draw lines
  line(x + 3, y + 3, x + size * 3 + spacing * 2 - 3, y + size * 3 + spacing * 2 - 3);
  line(x + size * 3 + spacing * 2 - 3, y + 3, x + 3, y + size * 3 + spacing * 2 - 3);

  doLineForks(x, y);
}

void doLineForks(int x, int y) {
  lineFork(x + size, y, 0);
  lineFork(x + spacing + size * 2, y, 0);
  lineFork(x + spacing * 2 + size * 3, y + size, 1);
  lineFork(x + spacing * 2 + size * 3, y + size * 2 + spacing, 1);
  lineFork(x + size, y + size * 3 + spacing * 2, 2);
  lineFork(x + size * 2 + spacing, y + size * 3 + spacing * 2, 2);
  lineFork(x, y + size, 3);
  lineFork(x, y + size * 2 + spacing, 3);
}

void extras(int x, int y) {
  int ellipseSize = 6;

  //colors
  stroke(#000000);
  strokeWeight(5);  

  line(x + size + spacing / 2, y - spacing / 2, x + spacing / 2, y - spacing / 2);
  ellipse(x + spacing / 2 - 7, y - spacing / 2, ellipseSize, ellipseSize);
  line(x + spacing / 2, y - spacing / 2, x + spacing / 2 - size, y - spacing / 2);
  //ellipse(x + spacing / 2 - size, y - spacing / 2, ellipseSize, ellipseSize);
  line(x + spacing / 2 - size, y - spacing / 2, x + spacing / 2 - size - spacing / 2, y - spacing / 2 + spacing / 2);
  drawTile(9, x - size - size, y - spacing / 2 + spacing / 2);

  line(x + size * 2 + spacing + spacing / 2, y + size * 3 + spacing * 2 + spacing / 2, x + size * 3 + spacing + spacing / 2, y + size * 3 + spacing * 2 + spacing / 2);
  ellipse(x + size * 3 + spacing + spacing / 2 + 7, y + size * 3 + spacing * 2 + spacing / 2, ellipseSize, ellipseSize);
  line(x + size * 3 + spacing + spacing / 2, y + size * 3 + spacing * 2 + spacing / 2, x + size * 4 + spacing + spacing / 2, y + size * 3 + spacing * 2 + spacing / 2);
  //ellipse(x + size * 4 + spacing + spacing / 2, y + size * 3 + spacing * 2 + spacing / 2, ellipseSize, ellipseSize);
  line(x + size * 4 + spacing + spacing / 2, y + size * 3 + spacing * 2 + spacing / 2, x + size * 5 + spacing + spacing / 2, y + size * 2 + spacing * 2 + spacing / 2);
  drawTile(10, x + size * 4 + spacing * 2, y + size * 2 + spacing * 2);
}

void lineFork(int x, int y, int rotation) {
  //colors
  stroke(#000000);
  strokeWeight(5);

  //draw lines
  switch(rotation) {
  case 0:
    line(x, y, x + spacing / 2, y - spacing / 2);
    line(x + spacing / 2, y - spacing / 2, x + spacing, y);
    break;
  case 1:
    line(x, y, x + spacing / 2, y + spacing / 2);
    line(x + spacing / 2, y + spacing / 2, x, y + spacing);
    break;
  case 2:
    line(x, y, x + spacing / 2, y + spacing / 2);
    line(x + spacing / 2, y + spacing / 2, x + spacing, y);
    break;
  default:
    line(x, y, x - spacing / 2, y + spacing / 2);
    line(x - spacing / 2, y + spacing / 2, x, y + spacing);
    break;
  }
}

void colors(color in) {
  fill(in);
  stroke(in);
}

int tileSection(int x, int y) {
  int centerX = x + size / 2;
  int centerY = y + size / 2;

  if (distance(mouseX, mouseY, x + size / 2, y + size / 2) < centerSize / 2 + 4) {
    return(0);
  } else if (mouseY - centerY >= abs(mouseX  - centerX)) {
    return(3);
  } else if (mouseX - centerX > abs(mouseY - centerY)) {
    return(2);
  } else if (-(mouseY - centerY) >= abs(mouseX - centerX)) {
    return(1);
  } else {
    return(4);
  }
}

boolean mouseInBox(int x, int y, int xSize, int ySize) {
  if (mouseX > x && mouseY > y && mouseX < x + xSize && mouseY < y + ySize) {
    return(true);
  } else {
    return(false);
  }
}

float distance(int x1, int y1, int x2, int y2) {
  return(sqrt(sq(x1 - x2)) + sq(y1 - y2));
}

void triangleCount(int xIn, int yIn, int triangle, int tile) {
  int tokenSize = 16;
  int extra = 10;
  pushStyle();
  strokeWeight(4);
  textSize(tokenSize);

  switch(triangle) {
  case 0:
    int x = xIn;
    int y = yIn;
    if (triangles[tile][triangle][0] != 0 || triangles[tile][triangle][1] != 0 || alwaysShow) {
      textAlign(LEFT, CENTER);
      fill(red);
      stroke(darkRed);
      ellipse(x + extra + tokenSize / 2, y - extra - tokenSize / 2, tokenSize, tokenSize);
      colors(#000000);
      text(triangles[tile][triangle][1], x + extra * 2 + tokenSize, y - extra - tokenSize / 2 - 2);

      textAlign(RIGHT, CENTER);
      fill(blue);
      stroke(darkBlue);
      ellipse(x + size - extra - tokenSize / 2, y - extra - tokenSize / 2, tokenSize, tokenSize);
      colors(#000000);
      text(triangles[tile][triangle][0], x + size - extra * 2 - tokenSize, y - extra - tokenSize / 2 - 2);
    }
    break;
  case 3:
    int x1 = xIn;
    int y1 = yIn + size;
    pushMatrix();
    if (triangles[tile][triangle][1] != 0 || triangles[tile][triangle][0] != 0 || alwaysShow) {
      translate(x1, y1);
      rotate(radians(-90));

      textAlign(LEFT, CENTER);
      fill(red);
      stroke(darkRed);
      ellipse(extra + tokenSize / 2, - extra - tokenSize / 2, tokenSize, tokenSize);
      colors(#000000);
      text(triangles[tile][triangle][0], extra * 2 + tokenSize, -extra - tokenSize / 2 - 2);

      textAlign(RIGHT, CENTER);
      fill(blue);
      stroke(darkBlue);
      ellipse(size - extra - tokenSize / 2, -extra - tokenSize / 2, tokenSize, tokenSize);
      colors(#000000);
      text(triangles[tile][triangle][1], size - extra * 2 - tokenSize, -extra - tokenSize / 2 - 2);
    }
    popMatrix();
    break;
  case 2:
    int x2 = xIn;
    int y2 = yIn + size;
    if (triangles[tile][triangle][0] != 0 || triangles[tile][triangle][1] != 0 || alwaysShow) {
      textAlign(LEFT, CENTER);
      fill(blue);
      stroke(darkBlue);
      ellipse(x2 + extra + tokenSize / 2, y2 + extra + tokenSize / 2, tokenSize, tokenSize);
      colors(#000000);
      text(triangles[tile][triangle][0], x2 + extra * 2 + tokenSize, y2 + extra + tokenSize / 2 - 2);

      textAlign(RIGHT, CENTER);
      fill(red);
      stroke(darkRed);
      ellipse(x2 + size - extra - tokenSize / 2, y2 + extra + tokenSize / 2, tokenSize, tokenSize);
      colors(#000000);
      text(triangles[tile][triangle][1], x2 + size - extra * 2 - tokenSize, y2 + extra + tokenSize / 2 - 2);
    }
    break;
  default:
    int x3 = xIn + size;
    int y3 = yIn;
    pushMatrix();
    if (triangles[tile][triangle][1] != 0 || triangles[tile][triangle][0] != 0 || alwaysShow) {
      translate(x3, y3);
      rotate(radians(90));

      textAlign(LEFT, CENTER);
      fill(red);
      stroke(darkRed);
      ellipse(extra + tokenSize / 2, - extra - tokenSize / 2, tokenSize, tokenSize);
      colors(#000000);
      text(triangles[tile][triangle][0], extra * 2 + tokenSize, -extra - tokenSize / 2 - 2);

      textAlign(RIGHT, CENTER);
      fill(blue);
      stroke(darkBlue);
      ellipse(size - extra - tokenSize / 2, -extra - tokenSize / 2, tokenSize, tokenSize);
      colors(#000000);
      text(triangles[tile][triangle][1], size - extra * 2 - tokenSize, -extra - tokenSize / 2 - 2);
    }
    popMatrix();

    break;
  }
}

void debug() {
  textAlign(CENTER, CENTER);
  for (int i = 0; i < locations.length; i++) {
    colors(#DEBB0B);
    ellipse(locations[i][0], locations[i][1], 15, 15);
    colors(#000000);
    text(i, locations[i][0], locations[i][1]);
  }
}

void mouseClicked() {
}

/*
 centers controlled by certain player (last one to be there)
 v/ no one starts with center circle
 v/ 1, 2, 3, 4, 10 controlled by blue
 v/ 6, 7, 8, 9, 11 controlled by red
 
 you can place 3 per turn in any triangles you are touching
 not home bases 
 v/ home bases are just center no triangles
 v/ (keep tally of red and blue in each triangle)
 each piece can only place one exceot for power piece wich places none
 
 v/ whoever has more tokens in triangle controlls triangle
 v/ 3 / 5 controlls square
 
 v/ 7 squares to win
 
 pieces move one space per turn
 infinite pieces on space
 
 one piece has two power
 five pieces with one power
 
 can't move to space someone else on other team is unless you out number them
 kick bback to connecting empty square except pone pieces came by
 die if nowhere to move
 
 if you take others home base they lose all points
 
 */

void doLocations() {
  locations[0][0] = 375 + spacing / 2 - size;
  locations[0][1] = 125 - spacing / 2;
  locations[1][0] = 375 + spacing / 2 - 10;
  locations[1][1] = 125 - spacing / 2;
  locations[2][0] = 375 + spacing / 2 + size;
  locations[2][1] = 125 - spacing / 2; 
  locations[3][0] = 375 + size * 2 + int(spacing * 1.5);
  locations[3][1] = 125 - spacing / 2;
  locations[4][0] = 375 - spacing * 2;
  locations[4][1] = 125;
  locations[5][0] = 375 - spacing;
  locations[5][1] = 125;
  locations[6][0] = 375;
  locations[6][1] = 125;
  locations[7][0] = 375 + size;
  locations[7][1] = 125; 
  locations[8][0] = 375 + size + spacing;
  locations[8][1] = 125;
  locations[9][0] = 375 + size * 2 + spacing;
  locations[9][1] = 125; 
  locations[10][0] = 375 + size * 2 + spacing * 2;
  locations[10][1] = 125; 
  locations[11][0] = 375 + size * 3 + spacing * 2;
  locations[11][1] = 125; 
  locations[12][0] = 375 - spacing - size / 2;
  locations[12][1] = 125 + size / 2; 
  locations[13][0] = 375 + size / 2;
  locations[13][1] = 125 + size / 2;
  locations[14][0] = 375 + size / 2 + spacing + size;
  locations[14][1] = 125 + size / 2; 
  locations[15][0] = 375 + size / 2 + spacing * 2 + size * 2;
  locations[15][1] = 125 + size / 2; 
  locations[16][0] = 375 - size * 2;
  locations[16][1] = 125 + size;
  locations[17][0] = 375 - size;
  locations[17][1] = 125 + size;
  locations[18][0] = 375;
  locations[18][1] = 125 + size;
  locations[19][0] = 375 + size;
  locations[19][1] = 125 + size; 
  locations[20][0] = 375 + size + spacing;
  locations[20][1] = 125 + size;
  locations[21][0] = 375 + size + spacing * 2;
  locations[21][1] = 125 + size; 
  locations[22][0] = 375 + size * 2 + spacing * 2;
  locations[22][1] = 125 + size; 
  locations[23][0] = 375 + size * 3 + spacing * 2;
  locations[23][1] = 125 + size; 
  locations[24][0] = 375 - spacing / 2;
  locations[24][1] = 125 + size + spacing / 2; 
  locations[25][0] = 375 + size * 3 + spacing * 2 + spacing / 2;
  locations[25][1] = 125 + size + spacing / 2; 
  locations[26][0] = 375;
  locations[26][1] = 125 + size + spacing;
  locations[27][0] = 375 + size;
  locations[27][1] = 125 + size + spacing; 
  locations[28][0] = 375 + size + spacing;
  locations[28][1] = 125 + size + spacing; 
  locations[29][0] = 375 + size * 2 + spacing;
  locations[29][1] = 125 + size + spacing; 
  locations[30][0] = 375 + size * 2 + spacing * 2;
  locations[30][1] = 125 + size + spacing; 
  locations[31][0] = 375 + size * 3 + spacing * 2;
  locations[31][1] = 125 + size + spacing;
  locations[32][0] = 375 + spacing / 2;
  locations[32][1] = 125 + size + spacing + spacing / 2; 
  locations[33][0] = 375 + spacing / 2 + size + spacing;
  locations[33][1] = 125 + size + spacing + spacing / 2; 
  locations[34][0] = 375 + spacing / 2+ size * 2 + spacing * 2;
  locations[34][1] = 125 + size + spacing + spacing / 2; 
  locations[35][0] = 375;
  locations[35][1] = 125 + size + spacing + size;
  locations[36][0] = 375 + size;
  locations[36][1] = 125 + size + spacing + size; 
  locations[37][0] = 375 + size + spacing;
  locations[37][1] = 125 + size + spacing + size; 
  locations[38][0] = 375 + size * 2 + spacing;
  locations[38][1] = 125 + size + spacing + size; 
  locations[39][0] = 375 + size * 2 + spacing * 2;
  locations[39][1] = 125 + size + spacing + size; 
  locations[40][0] = 375 + size * 3 + spacing * 2;
  locations[40][1] = 125 + size * 2 + spacing;
  locations[41][0] = 375 - spacing / 2;
  locations[41][1] = 125 + size * 2 + spacing / 2 + spacing; 
  locations[42][0] = 375 + size * 3 + spacing * 2 + spacing / 2;
  locations[42][1] = 125 + size * 2 + spacing + spacing / 2; 
  locations[43][0] = 375;
  locations[43][1] = 125 + size * 2 + spacing * 2;
  locations[44][0] = 375 + size;
  locations[44][1] = 125 + size * 2 + spacing * 2;
  locations[45][0] = 375 + size + spacing;
  locations[45][1] = 125 + size * 2 + spacing * 2; 
  locations[46][0] = 375 + size * 2 + spacing;
  locations[46][1] = 125 + size * 2 + spacing * 2; 
  locations[47][0] = 375 + size * 2 + spacing * 2;
  locations[47][1] = 125 + size * 2 + spacing * 2; 
  locations[48][0] = 375 + size * 3 + spacing * 2;
  locations[48][1] = 125 + size * 2 + spacing * 2; 
  locations[49][0] = 375 + size * 3 + spacing * 3;
  locations[49][1] = 125 + size * 2 + spacing * 2; 
  locations[50][0] = 375 + size * 4 + spacing * 3;
  locations[50][1] = 125 + size * 2 + spacing * 2; 
  locations[51][0] = 375 + size / 2;
  locations[51][1] = 125 + size * 2 + spacing * 2 + spacing / 2; 
  locations[52][0] = 375 + size / 2 + spacing + size;
  locations[52][1] = 125 + size * 2 + spacing * 2 + spacing / 2;
  locations[53][0] = 375 + size / 2 + size * 2 + spacing * 2;
  locations[53][1] = 125 + size * 2 + spacing * 2 + spacing / 2;
  locations[54][0] = 375 + size / 2 + spacing * 3 + size * 3;
  locations[54][1] = 125 + size * 2 + spacing * 2 + spacing / 2;
  locations[55][0] = 375;
  locations[55][1] = 125 + size * 3 + spacing * 2;
  locations[56][0] = 375 + size;
  locations[56][1] = 125 + size * 3 + spacing * 2; 
  locations[57][0] = 375 + size + spacing;
  locations[57][1] = 125 + size * 3 + spacing * 2; 
  locations[58][0] = 375 + size * 2 + spacing;
  locations[58][1] = 125 + size * 3 + spacing * 2; 
  locations[59][0] = 375 + size * 2 + spacing * 2;
  locations[59][1] = 125 + size * 3 + spacing * 2; 
  locations[60][0] = 375 + size * 3 + spacing * 2;
  locations[60][1] = 125 + size * 3 + spacing * 2; 
  locations[61][0] = 375 + size * 3 + spacing * 3;
  locations[61][1] = 125 + size * 3 + spacing * 2; 
  locations[62][0] = 375 + size * 4 + spacing * 3;
  locations[62][1] = 125 + size * 3 + spacing * 2; 
  locations[63][0] = 375 + size + spacing / 2;
  locations[63][1] = 125 + size * 3 + spacing * 2 + spacing / 2; 
  locations[64][0] = 375 + size * 2 + spacing + spacing / 2;
  locations[64][1] = 125 + size * 3 + spacing * 2 + spacing / 2; 
  locations[65][0] = 375 + size * 2 + spacing * 2 + spacing / 2 + 10;
  locations[65][1] = 125 + size * 3 + spacing * 2 + spacing / 2; 
  locations[66][0] = 375 + size * 3 + spacing * 2 + spacing / 2;
  locations[66][1] = 125 + size * 3 + spacing * 2 + spacing / 2;
}

class Piece {
  int square, x, y;
  boolean myColor, power;

  Piece(int squareIn, boolean myColorIn, boolean powerIn) {
    square = squareIn;
    x = locations[square][0];
    y = locations[square][1];
    myColor = myColorIn;
    power = powerIn;
  }

  void doDraw() {
    strokeWeight(5);
    if (myColor) {
      if (power) {
        fill(darkRed);
      } else {
        fill(red);
      }
      stroke(darkRed);
    } else {
      if (power) {
        fill(darkBlue);
      } else {
        fill(blue);
      }
      stroke(darkBlue);
    }
    ellipse(x, y, pieceSize, pieceSize);
    if (power) {
      strokeWeight(3);
      if (myColor) {
        colors(red);
      } else {
        colors(blue);
      }
      line(x, y + pieceSize / 2, x, y - pieceSize / 2);
      line(x + pieceSize / 2, y, x - pieceSize / 2, y);
    }
  }

  void pieceMove() {
  }
  
  void centerUpdate(){
    if(listContains(centers, square)){
      centerControl[centerNumber(square)] = myColor;
      if(square == 33){
        centerTaken = true;
      }
    }
  }

  int place() {
    return(square);
  }
}


Hi,

It would help us a lot if you could provide your code.

Its around five hundred lines but I’ll edit my comment.

I let the sketch ran for half an hour and nothing happened… This is your full code?

Yes…
How much memory allocation do you have. mine is just the default 256 mb

I just tried again and it took 15 minutes

As @jb4x said, I also ran the sketch for awhile and nothing happened.

Other than that, I’m not sure if this is possible for your sketch, but instead of rendering 50+ points and lines you can put them into a PShape in the beginning then render them all together, and it should decrease the memory usage.

The sketches frameRate is around 40 for me, which is below the default 60 so you might want to look into optimizing it.