package com.fteams.siftrain.util.random; import com.badlogic.gdx.utils.Array; import com.fteams.siftrain.assets.GlobalConfiguration; import com.fteams.siftrain.objects.CircleMark; import com.fteams.siftrain.util.SongUtils; import java.util.HashMap; import java.util.Map; public class ExtremeRandomizer extends Randomizer { /* * Info: this is the only randomizer which works with ANY BEATMAP (even those with more than 2 notes at the same time!) */ public void randomize(Array<CircleMark> marks) { // sort marks by timing marks.sort(); double threshold = SongUtils.getDefaultNoteSpeedForApproachRate(GlobalConfiguration.noteSpeed) / 32.0; for (int i = 0 ; i < marks.size; i++) { CircleMark mark = marks.get(i); Integer pos = getFreePosition(mark.getNote().timing_sec); noteToReleaseTime.put(pos, mark.getNote().timing_sec + (mark.hold ? mark.getNote().effect_value : 0) + threshold); mark.updateDestination(pos); } } private Integer getFreePosition(Double timing_sec) { Integer position = (int)(Math.random() * 100) % 9; while (inUse(position, timing_sec) ) { position = (int)(Math.random() * 100) % 9; } return position; } }