void InitializePatternDiff() {
    patternId = new int[NUM_DISK][NUM_PATTERN_DIFF];
    patternDiff = new int[NUM_DISK][NUM_PATTERN_DIFF];

    int i, j, k;
    for (i=0; i < NUM_DISK; i++) {
      for (j=0; j < NUM_PATTERN_DIFF; j++) {
        patternId[i][j] = 0;
        patternDiff[i][j] = 0;
      }
    }

    for (i = 0; Pattern.list[i][0] >= 0; i++) {
      int n = 1;
      for (j = 0; Pattern.list[i][j] >= 0; j++) {
        for (k=0; patternDiff[Pattern.list[i][j]][k] != 0; k++){}
        patternId[Pattern.list[i][j]][k] = i;
        patternDiff[Pattern.list[i][j]][k] = n;
        n *= 3;
      }
    }

    if (Debug.state) {
      for (i=0; i < NUM_DISK; i++) {
        for (j=0; j < NUM_PATTERN_DIFF && patternDiff[i][j] > 0; j++) {
          Debug.println("Diff(" + i + "," + j + ")=" + patternId[i][j] + "," + patternDiff[i][j]); 
        }
      }
    }
  }