-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctionlib.py
More file actions
177 lines (168 loc) · 4.35 KB
/
functionlib.py
File metadata and controls
177 lines (168 loc) · 4.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
from json import dump
from math import hypot
from sympy import Line
def modToRaw(score, mods):
##########################################
# List of mods #
# NF, NA, NO, NB, SS, IF, BE, DA, FS, GN #
##########################################
mod = 1
if 'NO' in mods:
mod = mod - 0.95
if 'NB' in mods:
mod = mod - 0.90
if 'SS' in mods:
mod = mod - 0.70
if 'IF' in mods:
mod = mod + 0.16
if 'BE' in mods:
mod = mod + 0.10
if 'DA' in mods:
mod = mod + 0.07
if 'FS' in mods:
mod = mod + 0.08
if 'GN' in mods:
mod = mod + 0.11
if 'NA' in mods:
mod = 0
if 'NF' in mods:
mod = 0
score = score * mod
round(score, 0)
return score
def scoreToAcc(notes, score):
notes = notes - 14
a = notes*920
b = a+4830
acc = round((score/b)*100, 4)
return acc
def getScore(userID, acc, weight):
f = (-0.0000000089146*acc**5)+(0.0000036255812*acc**4)+(-0.0004061889074*acc**3)+(0.003306769423*acc**2)+(1.9970958028178*acc)
if (0 <= acc <= 135):
g = (2*acc)-(f)
h = g/100
else:
h = 0
cp = round(weight*h, 2)
return cp
def getLenght(x1, x2, y1, y2):
c = hypot(x2 - x1, y2 - y1)
return c
def getNotes(file):
lines = open(file, "r").read().split('\"_notes\":[')
notes = str(lines[1]).split('],"_obstacles":')
return notes[0]
def createChunks(notes):
notesarray = str(notes).split(',')
###############
# Beat 0 dict #
###############
a = 0 # While loop counter
d = 0 # Begin of chunk
b = 2 # End of chunk
e = 0 # Chunk Naming
chunk = []
chunkdict = {}
while a < len(notesarray):
c = str(notesarray[a]).split(':')
if c[0] == '{"_time"':
if float(c[1]) >= b:
chunkdict[f'chunk{e}'] = chunk
chunk = []
d = d + 2
b = b + 2
e = e + 1
if float(c[1]) >= d and float(c[1]) <= b:
chunk.append(f'{notesarray[a]},{notesarray[a+1]},{notesarray[a+2]},{notesarray[a+3]},{notesarray[a+4]}')
a = a + 1
with open("dict0.json", "w") as outfile:
dump(chunkdict, outfile)
###############
# Beat 1 dict #
###############
a = 0 # While loop counter
d = 1 # Begin of chunk
b = 3 # End of chunk
e = 0 # Chunk Naming
chunk = []
chunkdict = {}
while a < len(notesarray):
c = str(notesarray[a]).split(':')
if c[0] == '{"_time"':
if float(c[1]) >= b:
chunkdict[f'chunk{e}'] = chunk
chunk = []
d = d + 2
b = b + 2
e = e + 1
if float(c[1]) >= d and float(c[1]) <= b:
chunk.append(f'{notesarray[a]},{notesarray[a+1]},{notesarray[a+2]},{notesarray[a+3]},{notesarray[a+4]}')
a = a + 1
with open("dict1.json", "w") as outfile:
dump(chunkdict, outfile)
def notesToAngle(CutDir1, x1, y1, CutDir2, x2, y2):
x3 = 0
y3 = 0
x4 = 0
y4 = 0
if CutDir1 == 0:
x3 = x1
y3 = y1 + 1
elif CutDir1 == 1:
x3 = x1
y3 = y1 - 1
elif CutDir1 == 2:
x3 = x1 - 1
y3 = y1
elif CutDir1 == 3:
x3 = x1 + 1
y3 = y1
elif CutDir1 == 4:
x3 = x1 - 1
y3 = y1 + 1
elif CutDir1 == 5:
x3 = x1 + 1
y3 = y1 + 1
elif CutDir1 == 6:
x3 = x1 - 1
y3 = y1 - 1
elif CutDir1 == 7:
x3 = x1 + 1
y3 = y1 - 1
elif CutDir1 == 8:
x3 = x1 + 1
y3 = y1 + 1
elif CutDir2 == 0:
x4 = x2
y4 = y2 + 1
elif CutDir2 == 1:
x4 = x2
y4 = y2 - 1
elif CutDir2 == 2:
x4 = x2 - 1
y4 = y2
elif CutDir2 == 3:
x4 = x2 + 1
y4 = y2
elif CutDir2 == 4:
x4 = x2 - 1
y4 = y2 + 1
elif CutDir2 == 5:
x4 = x2 + 1
y4 = y2 + 1
elif CutDir2 == 6:
x4 = x2 - 1
y4 = y2 - 1
elif CutDir2 == 7:
x4 = x2 + 1
y4 = y2 - 1
elif CutDir2 == 8:
x4 = x2 + 1
y4 = y2 + 1
try:
a = Line((x1, y1), (x3, y3))
b = Line((x2, y2), (x4, y4))
angle = a.smallest_angle_between(b)
except ValueError:
angle = 0
return angle