Skip to content

Commit

Permalink
corner the object only if it's truly impossible
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakads committed Nov 8, 2019
1 parent 5f72e0d commit 2b2d728
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
23 changes: 12 additions & 11 deletions src/catch.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ def randosu(path, content):
TrueRandom = True if choose() else False

if not TrueRandom:
min = inputnum('Min Scale Factor(Default: 0.8): ', 0.8)
max = inputnum('Max Scale Factor(Default: 1.5): ', 1.5)
minsf = inputnum('Min Scale Factor(Default: 0.8): ', 0.8)
maxsf = inputnum('Max Scale Factor(Default: 1.5): ', 1.5)

# I bet someone would try this so
if min > max:
tmp = min
min = max
max = tmp
if minsf > maxsf:
tmp = minsf
minsf = maxsf
maxsf = tmp

red = inputnum('Chance of Red Anchors(%, default 25): ', 25)

Expand All @@ -76,8 +76,8 @@ def randosu(path, content):
diffname = c.split(':', 1)[1][:-1]
index = content.index(c)

rand = f"truerand({red})" if TrueRandom else f"rand({min}~{max},{red})"
Rand = f"TrueRandomized(Red:{red}%)" if TrueRandom else f"Randomized({min}~{max}x, Red:{red}%)"
rand = f"truerand({red})" if TrueRandom else f"rand({minsf}~{maxsf},{red})"
Rand = f"TrueRandomized(Red:{red}%)" if TrueRandom else f"Randomized({minsf}~{maxsf}x, Red:{red}%)"

content[index] = f'Version:{Rand}_{diffname} (Seed:{randseed})\n'
filename = f'{os.path.dirname(path)}\\{rand}_{randseed}_{sanitize_filename(diffname)}.osu'
Expand All @@ -96,15 +96,16 @@ def randosu(path, content):
# Add 0~10 for chaos
diffx = n['x'] - notes[i-1]['x'] + uniform(0, 10)

factor = uniform(min, max)
factor = uniform(minsf, maxsf)

if randint(0, 1):
randx = randnotes[i-1]['x'] + int(diffx * factor)
else:
randx = randnotes[i-1]['x'] - int(diffx * factor)

# If factor is too high, corner the object
if abs(int(diffx * factor)) > 1200:
# If factor is too high, corner the object, but only if it's truly impossible
prevx = randnotes[i-1]['x']
if abs(diffx) * minsf > max([prevx, 512-prevx]):
if randx < 0:
randx = 0
if randx > 512:
Expand Down
29 changes: 16 additions & 13 deletions src/std.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ def randosu(path, content):
TrueRandom = True if choose() else False

if not TrueRandom:
min = inputnum('Min Scale Factor(Default: 0.8): ', 0.8)
max = inputnum('Max Scale Factor(Default: 1.5): ', 1.5)
minsf = inputnum('Min Scale Factor(Default: 0.8): ', 0.8)
maxsf = inputnum('Max Scale Factor(Default: 1.5): ', 1.5)

# I bet someone would try this so
if min > max:
tmp = min
min = max
max = tmp
if minsf > maxsf:
tmp = minsf
minsf = maxsf
maxsf = tmp

red = inputnum('Chance of Red Anchors(%, default 25): ', 25)

Expand All @@ -79,8 +79,8 @@ def randosu(path, content):
diffname = c.split(':', 1)[1][:-1]
index = content.index(c)

rand = f"truerand({red})" if TrueRandom else f"rand({min}~{max},{red})"
Rand = f"TrueRandomized(Red:{red}%)" if TrueRandom else f"Randomized({min}~{max}x, Red:{red}%)"
rand = f"truerand({red})" if TrueRandom else f"rand({minsf}~{maxsf},{red})"
Rand = f"TrueRandomized(Red:{red}%)" if TrueRandom else f"Randomized({minsf}~{maxsf}x, Red:{red}%)"

content[index] = f'Version:{Rand}_{diffname} (Seed:{randseed})\n'
filename = f'{os.path.dirname(path)}\\{rand}_{randseed}_{sanitize_filename(diffname)}.osu'
Expand All @@ -102,16 +102,19 @@ def randosu(path, content):
diffx = n['x'] - notes[i-1]['x'] + uniform(0, 10)
diffy = n['y'] - notes[i-1]['y'] + uniform(0, 10)

distance = (diffx ** 2 + diffy ** 2) ** 0.5
d = lambda x, y: (x ** 2 + y ** 2) ** 0.5
distance = d(diffx, diffy)

rad += 2 * pi * uniform(-1, 1) ** 3
factor = uniform(min, max)
rad += 2 * pi * uniform(-1, 1) ** 5
factor = uniform(minsf, maxsf)

randx = randnotes[i-1]['x'] + int(distance * factor * cos(rad))
randy = randnotes[i-1]['y'] + int(distance * factor * sin(rad))

# If factor is too high, corner the object
if int(distance * factor) > 640:
# If factor is too high, corner the object, but only if it's truly impossible
prevx = randnotes[i-1]['x']
prevy = randnotes[i-1]['y']
if distance * minsf > max([d(prevx, prevy), d(512-prevx, prevy), d(prevx, 384-prevy), d(512-prevx, 384-prevy)]):
if randx < 0:
randx = 0
if randx > 512:
Expand Down

0 comments on commit 2b2d728

Please sign in to comment.