-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearchSeed.py
executable file
·45 lines (36 loc) · 1.12 KB
/
searchSeed.py
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
#!/usr/bin/python
import sys
import os
import time
problem = sys.argv[1]
output = sys.argv[2]
bestSeed = -1
bestErr = 2
bestTime = 1
def notify(title, subtitle, message):
t = '-title {!r}'.format(title)
s = '-subtitle {!r}'.format(subtitle)
m = '-message {!r}'.format(message)
os.system('terminal-notifier {}'.format(' '.join([m, t, s])))
def printFile():
notify("Seed Search", "new seed", str(bestErr)+" - "+bestSeed+" - "+str(bestTime))
with open(output, "a") as file:
file.write(str(bestErr)+" - "+bestSeed+" - "+str(bestTime)+"\n")
with open(output,"a") as file:
file.write("\n----------------------------------------------\n")
while True:
start = time.time()
retValues = os.popen("java -cp target/classes Main "+problem+" 0" ).readlines()
end = time.time()
err = float(retValues[0].strip())
seed = retValues[1].strip()
if err == bestErr:
if bestTime > end-start:
bestTime = end-start
bestSeed = seed
printFile()
if err < bestErr:
bestErr = err
bestTime = end-start
bestSeed = seed
printFile()