code: public int countSharedAlleles(int allelesCount, Genotype genotypeFirst, Genotype genotypeSecond) {
  
          // amount of different alleles: reference, alternate. other alleles (missing, or multiallelic) are ignored
          int[] allelesCountsFirst = new int[2];
          int[] allelesCountsSecond = new int[2];
  
          for (int k = 0; k < allelesCount; k++) {
              if (genotypeFirst.getAllele(k) == 0) {
                  allelesCountsFirst[0]++;
              } else if (genotypeFirst.getAllele(k) == 1) {
                  allelesCountsFirst[1]++;
              }
              if (genotypeSecond.getAllele(k) == 0) {
                  allelesCountsSecond[0]++;
              } else if (genotypeSecond.getAllele(k) == 1) {
                  allelesCountsSecond[1]++;
              }
          }
  
          int whichIBS = Math.min(allelesCountsFirst[0], allelesCountsSecond[0])
                  + Math.min(allelesCountsFirst[1], allelesCountsSecond[1]);
  
          return whichIBS;
      }
docs: Counts the amount of shared alleles in two individuals.
  This is which IBS kind is this pair: IBS0, IBS1 or IBS2.
  The idea is to count how many alleles there are of each kind: for instance, 0 reference alleles for individual 1
  and 2 reference alleles for individual 2, and then count the alternate alleles. Then take the minimum of each
  kind and sum all the minimums.
  @param allelesCount ploidy
  @param genotypeFirst first individual's genotype
  @param genotypeSecond second individual's genotype
  @return shared alleles count.