Move and MoveList

class Move {
  int row;
  int col;
  color c;
  
  Move(int in_row, int in_col, color in_c) {
    row = in_row;
    col = in_col;
    c = in_c;
  }
 
  Move(Move another) {
    this(another.row,another.col,another.c);
  }

  String toString() {
    return str(row)+","+str(col)+" ("+red(c)+","+green(c)+","+blue(c)+")";
  }
}

// This is a dynamic array of Move objects

class MOVELIST {
  Move[] moves;
  int filled;
  
  // create an array of initSize of Move objects
  MOVELIST(int initSize) {
    moves = new Move[initSize];
    filled = 0;
  }
  
  Move get(int index) {
    if (index < 0 || index >= filled)
      return null;
    return moves[index];
  }
  
  void append(int row, int col, color c) {
    if (filled < moves.length) {
      moves[filled] = new Move(row,col,c);
      ++filled;
      return;
    }
    
    // not enough room, create an array twice the size of the previous one
    Move[] newMoves = new Move[moves.length * 2];
    // copy the old references to the objects over
    for (int i = 0; i < moves.length*2; ++i) {
      if (i < filled) {
        newMoves[i] = moves[i];
      }
    }
    // now switch over, abandoning the older moves[] array to the garbage collector
    moves = newMoves;
    
    // now that there is more room, append it
    this.append(row,col,c);
  }
}