@SuppressWarnings("unchecked")
  @Override
  public void map(LongWritable positionToMap, LongWritable record, Context context) {
    try {
      S pos = game.hashToState(positionToMap.get());
      game.longToRecord(pos, record.get(), rec);
      rec.previousPosition();

      int numParents = 0;
      numParents = ((Undoable<S>) game).possibleParents(pos, parentStates);

      for (int i = 0; i < numParents; i++) {
        long parentHash = game.stateToHash(parentStates[i]);
        RangeFile parentFile = rangeFiles.getFile(parentHash);

        srp.state = parentHash;
        srp.record = game.recordToLong(parentStates[i], rec);

        context.write(parentFile, new StateRecordPair(srp.state, srp.record));
      }
    } catch (IOException e) {
      throw new Error(e);
    } catch (InterruptedException e) {
      e.printStackTrace();
    }
  }