@Override
 public void reset() {
   LEDUtil.clear(ledManager);
   colorSeed = random.nextInt();
   for (int i = 0; i < boxCount; i++) {
     moving[i] = 0;
     directions[i] = new Vector3();
     do {
       offsets[i] =
           new Vector3(
               random.nextInt(dimension.x / boxSize) * boxSize,
               random.nextInt(dimension.x / boxSize) * boxSize,
               random.nextInt(dimension.x / boxSize) * boxSize);
     } while (!isFreeSpace(offsets[i]));
     drawBox(i, offsets[i]);
   }
 }
 @Override
 public void refresh() {
   if (ticks % 3 == 0) {
     LEDUtil.clear(ledManager);
     boolean boxMoving = false;
     for (int i = 0; i < boxCount; i++) {
       if (moving[i] > 0) {
         boxMoving = true;
         moving[i]--;
         offsets[i] = offsets[i].add(directions[i]);
       }
       drawBox(i, offsets[i]);
     }
     if (!boxMoving) {
       int[] boxes = new int[boxCount];
       for (int i = 0; i < boxCount; i++) {
         boxes[i] = i;
       }
       Util.shuffleArray(boxes, random);
       Direction[] dirs =
           Arrays.copyOf(Direction.VALID_DIRECTIONS, Direction.VALID_DIRECTIONS.length);
       Util.shuffleArray(dirs, random);
       boxloop:
       for (int i = 0; i < boxCount; i++) {
         int box = boxes[i];
         if (boxCount > 1 && box == lastMoved) continue;
         for (Direction dir : dirs) {
           Vector3 pos = offsets[box].add(dir.getVector().multiply(boxSize));
           if (isFreeSpace(pos)) {
             directions[box] = dir.getVector();
             moving[box] = boxSize;
             lastMoved = box;
             break boxloop;
           }
         }
       }
     }
   }
 }